0 | |
.TH "BCAL" "1" "Apr 2017" "Version 1.5" "User Commands"
|
|
0 |
.TH "BCAL" "1" "Jun 2017" "Version 1.6" "User Commands"
|
1 | 1 |
.SH NAME
|
2 | 2 |
bcal \- Perform storage conversions and calculations.
|
3 | 3 |
.SH SYNOPSIS
|
4 | |
.B bcal [-c N] [-f FORMAT] [-s bytes] [-h]
|
|
4 |
.B bcal [-c N] [-f FORMAT] [-s bytes] [-d] [-h]
|
5 | 5 |
.br
|
6 | |
.B " "[N unit]
|
|
6 |
.B " "[expression] [N [unit]]
|
7 | 7 |
.SH DESCRIPTION
|
8 | 8 |
.B bcal
|
9 | 9 |
(Byte CALculator) is a command-line utility to help with numerical calculations involving data storage units, addressing, base conversions etc.
|
10 | 10 |
.PP
|
11 | 11 |
.B Features
|
12 | 12 |
.PP
|
|
13 |
* evaluate arithmetic expressions involving storage units
|
13 | 14 |
* convert to IEC/SI standard data storage units
|
14 | 15 |
* show the address in bytes
|
|
16 |
* evaluate arithmetic expression of storage units
|
15 | 17 |
* show address as LBA:OFFSET
|
16 | 18 |
* convert CHS to LBA and vice versa
|
17 | 19 |
* show binary, decimal and hex representation of a number
|
|
25 | 27 |
.SH OPERATIONAL NOTES
|
26 | 28 |
.PP
|
27 | 29 |
.IP 1. 4
|
28 | |
\fBN unit\fR: \fIN\fR can be a decimal or '0x' prefixed hex value. \fIunit\fR can be B/KiB/MiB/GiB/TiB/kB/MB/GB/TB following Ubuntu policy. As all of these tokens are unique, \fIunit\fR is case-insensitive. \fIN\fR and \fIunit\fR must be space-separated.
|
|
30 |
\fBExpression\fR: An expression must be within double quotes. Inner spaces are ignored. A storage unit can only be multiplied or divided by positive integers. Only storage units can be used for addition and subtraction.
|
29 | 31 |
.PP
|
30 | 32 |
.IP 2. 4
|
31 | |
Decimal and hex \fBnumeric representations\fR are recognized for unit conversions. Decimal, hex, binary and octal are recognized for all other operations.
|
|
33 |
\fBN [unit]\fR: \fIN\fR can be a decimal or '0x' prefixed hex value. \fIunit\fR can be B/KiB/MiB/GiB/TiB/kB/MB/GB/TB following Ubuntu policy. Default is byte. As all of these tokens are unique, \fIunit\fR is case-insensitive.
|
32 | 34 |
.PP
|
33 | 35 |
.IP 3. 4
|
|
36 |
Only decimal is recognized in expressions. Decimal and hex \fBnumeric representations\fR are recognized for unit conversions. Decimal, hex, binary and octal are recognized for all other operations.
|
|
37 |
.PP
|
|
38 |
.IP 4. 4
|
34 | 39 |
\fBSyntax\fR: Prefix hex inputs with '0x', binary inputs with '0b', octal inputs with '00'.
|
35 | 40 |
.PP
|
36 | |
.IP 4. 4
|
|
41 |
.IP 5. 4
|
37 | 42 |
\fBNo negative arguments\fR allowed. Input limits are \fIunsigned long long\fR and \fIdouble\fR.
|
38 | 43 |
.PP
|
39 | |
.IP 5. 4
|
|
44 |
.IP 6. 4
|
40 | 45 |
\fBFractional bytes do not exist\fR, because they can't be addressed. \fBbcal\fR shows the floor value of non-integer bytes.
|
41 | 46 |
.PP
|
42 | |
.IP 6. 4
|
|
47 |
.IP 7. 4
|
43 | 48 |
\fBCHS and LBA syntax\fR:
|
44 | 49 |
- LBA: 'lLBA-MAX_HEAD-MAX_SECTOR' [NOTE: LBA starts with 'l' (case ignored)]
|
45 | 50 |
- CHS: 'cC-H-S-MAX_HEAD-MAX_SECTOR' [NOTE: CHS starts with 'c' (case ignored)]
|
46 | 51 |
- Format conversion arguments must be hyphen separated.
|
47 | 52 |
- Any unspecified value, including the one preceding the first '-' to the one following the last '-', is considered '0' (zero).
|
48 | 53 |
.PP
|
49 | |
.IP 7. 4
|
|
54 |
.IP 8. 4
|
50 | 55 |
\fBDefault values\fR:
|
51 | 56 |
- sector size: 0x200 (512)
|
52 | 57 |
- max heads per cylinder: 0x10 (16)
|
|
68 | 73 |
.BI "-s=" bytes
|
69 | 74 |
Sector size in bytes. Default value is 512.
|
70 | 75 |
.TP
|
|
76 |
.BI "-m"
|
|
77 |
Show minimal output (e.g. decimal bytes).
|
|
78 |
.TP
|
|
79 |
.BI "-d"
|
|
80 |
Enable debug information and logs.
|
|
81 |
.TP
|
71 | 82 |
.BI "-h"
|
72 | 83 |
Show program help and exit.
|
73 | 84 |
.SH EXAMPLES
|
74 | 85 |
.PP
|
75 | 86 |
.IP 1. 4
|
|
87 |
Evaluate arithmetic expression of storage units
|
|
88 |
.PP
|
|
89 |
.EX
|
|
90 |
.IP
|
|
91 |
.B $ bcal """(5kb+2mb)/3"""
|
|
92 |
.B $ bcal """5 tb / 12"""
|
|
93 |
.B $ bcal """2.5mb*3"""
|
|
94 |
.EE
|
|
95 |
.PP
|
|
96 |
.IP 2. 4
|
76 | 97 |
Convert storage capacity to other units and get address, LBA.
|
77 | 98 |
.PP
|
78 | 99 |
.EX
|
|
81 | 102 |
.B $ bcal 0x1335053 B
|
82 | 103 |
.B $ bcal 0xaabbcc kb
|
83 | 104 |
.B $ bcal 0xdef Gib
|
84 | |
|
85 | 105 |
Note that the units are case-insensitive.
|
86 | 106 |
.EE
|
87 | 107 |
.PP
|
88 | |
.IP 2. 4
|
|
108 |
.IP 3. 4
|
89 | 109 |
Convert storage capacity, set sector size to 4096 to calculate LBA.
|
90 | 110 |
.PP
|
91 | 111 |
.EX
|
|
93 | 113 |
.B $ bcal 0xaabbcc kb -s 4096
|
94 | 114 |
.EE
|
95 | 115 |
.PP
|
96 | |
.IP 3. 4
|
|
116 |
.IP 4. 4
|
97 | 117 |
Convert LBA to CHS.
|
98 | 118 |
.PP
|
99 | 119 |
.EX
|
|
103 | 123 |
.B $ bcal -f l0x300-0x12-0x7e
|
104 | 124 |
.EE
|
105 | 125 |
.PP
|
106 | |
.IP 4. 4
|
|
126 |
.IP 5. 4
|
107 | 127 |
Convert CHS to LBA.
|
108 | 128 |
.PP
|
109 | 129 |
.EX
|
|
115 | 135 |
.B $ bcal -f c0x10-10--0x12
|
116 | 136 |
.EE
|
117 | 137 |
.PP
|
118 | |
.IP 5. 4
|
|
138 |
.IP 6. 4
|
119 | 139 |
Show binary, decimal and hex representations of a number.
|
120 | 140 |
.PP
|
121 | 141 |
.EX
|