DragonFly On-Line Manual Pages
FB(1) DragonFly General Commands Manual FB(1)
NAME
fb - binary file viewer, editor, and manipulator
SYNOPSIS
fb [[-AaBbCcDdEeHhKkLlNnOoSsTt] [-i INC] [-r RNG] [-p PS]
File] | [r RNG BYTE File] | [a|c RNG File1 [File2]] |
[t[ ]b|d|h|o File1 [File2]] | [b|d|h|o|-|. File1 File2] |
[- c|h|n|v]
DESCRIPTION
fb provides interactive browsing of a file or the contents of a file
can be streamed (without interaction) to standard output. The file can
be viewed in binary, octal, decimal, hexadecimal, or characters.
Optionally, fb will read standard input if option -t is in effect and
"-" is given as the file name. Output consists of "pages" of one or
more lines. Each line of a page consists of the offset from the
beginning of the file in decimal (optional if non-interactive),
followed first by one or more columns of an optional numeric display in
either binary, octal, decimal, or hexadecimal; and this, in turn,
followed by an optional character display; however, at least one of the
two displays must be present. Unprintable characters will show as a
period. By default, fb has a hexadecimal numeric display along with a
character display.
fb also has a limited editing capability if invoked with the -e option
and the file is writable. In edit mode, the user can specify which
bytes in the file to overwrite. These bytes can be overwritten in
either binary, octal, decimal, hexadecimal, or character formats. The
format in effect is in agreement with the current display.
fb also has five helper methods: append, copy, translate, replace, and
compare. The append method allows for copying a selection of the
contents of one file to the end of another or the same file. If the
second file does not exist, it is created. The copy method allows for
copying a selection of the contents of one file to another or the same
file. Be aware that the second file is overwritten; in particular,
copying a file to itself will reduce the file to the size of the
portion that was copied.
The translate method will convert either binary, octal, decimal, or
hexadecimal numbers in one file into bytes and copy these bytes to
another or the same file. Or the translate will convert numbers from
standard input into bytes and copy these to a file. The numbers can
optionally be delimited with any character that is not a digit for the
given base and is not the character "|". The "|" character is used to
indicate the start of a comment. The "|" character and all characters
after it to the end of line will be ignored. At any place in the file
where the numbers are not delimited, 8 digits (for binary), 3 digits
(for octal and decimal), and 2 digits (for hexadecimal) will be
converted at a time.
The replace method will replace all of the bytes in a specified portion
of a file with a particular value.
The compare method will report the offsets where two files differ and
the value of the bytes (in binary, decimal, hexadecimal, or octal) at
these offsets till the end of the shortest file. If the lengths of the
files are different, it will also report the end of file (EOF) for both
files. The exit status of the compare method is one of five values: 0
- files the same, 1 - an error has occurred, 2 - bytes differ, 3 -
sizes differ, and 4 - bytes and sizes differ. Optionally the compare
method can report only if the files differ and how or it can run
silent: returning only the exit status.
OPTIONS
Base options:
-b Binary numbers (8 columns).
-B Binary numbers (16 columns).
-d Decimal numbers (16 columns).
-D Decimal numbers (32 columns).
-h Hexadecimal numbers (16 columns).
-H Hexadecimal numbers (32 columns).
-o Octal numbers (16 columns).
-O Octal numbers (32 columns).
Display options:
-a Suppress offset addresses. (Ignored if effective mode is
interactive.)
-A Display offset addresses.
-c Characters only (64 columns).
-C Characters only (128 columns).
-k Numeric display is compressed (no spaces between numbers).
-K Numeric display is not compressed (spaces between numbers).
-l Suppress column labels.
-L Display column labels.
-n Exclude supplemental character display.
-N Include supplemental character display.
Mode options:
-e Edit mode. (Ignored if effective mode is non-interactive.)
-E Read-only mode.
-s Stream output (non-interactive mode).
-S Interactive mode. (Will nullify previous -s or -t options.)
-t Read from standard input and stream output (non-interactive
mode). (Will nullify previous -S or -T options.) Note: File
name MUST be "-".
-T Read from File.
Options with arguments:
-i INC Increment page INC bytes. INC is a nonnegative integer. 0 sets
increment to default, (number of rows)*(number of columns).
-r RNG Portion of File to browse. RNG is Start | [Start].[Stop]; where
Start (default: 0) and Stop (default: end of file) are the
starting and stopping offsets of File.
-p PS Page size. PS is Rw | [Rw].[Cl]. Rw is number of rows, range
[0..64] (default: 16). Cl is number of columns, range [0..128]
(default: specified by either the base option or -c,-C options).
Note: 0 for either Rw or Cl will also invoke their defaults.
Note: Options are evaluated left-to-right. When options are mutually
exclusive, only last one is effective.
fb File
is the same as fb -hAEKLNST -p . -r . -i 0 File
Append and Copy methods:
fb a RNG File1 [File2]
fb c RNG File1 [File2]
Copy bytes in range RNG from File1 and append/copy to File1 or
optional File2. RNG is Start | [Start].[Stop]; where Start
(default: 0) is the offset in File1 where copying should start
and Stop (default: end of file) is offset where copying should
stop.
Translate method:
fb t[ ]b|d|h|o File1 [File2]
Convert binary|decimal|hexadecimal|octal numbers in File1 (or
standard input if no space is present between "t" and base
indicator) into bytes and copy bytes to File1 (or to optional
File2 if input is NOT from standard input). See under notes
(below) for more information.
Replace method:
fb r RNG BYTE File
Replace bytes in range RNG of File with value BYTE [0..255].
RNG is Start | [Start].[Stop]; where Start (default: 0) is the
offset in File where replacement should start and Stop (default:
end of file) is the offset where replacement should stop.
Compare method:
fb b|d|h|o|-|. File1 File2
Report offsets and byte values (in
binary|decimal|hexadecimal|octal) where File1 and File2 differ
till end of shortest file. If file lengths differ, report end
of file (EOF) for both files. With option "-" report only if
files differ and how. With option "." return exit status only:
0 - files the same, 1 - error, 2 - bytes differ, 3 - sizes
differ, 4 - bytes and sizes differ.
Switches:
- c List interactive commands.
- h Display help page.
- n Display notes concerning fb.
- v Show current version information.
Note: A space MUST be present between "-" and either c, h, n, or
v.
COMMANDS
+<number>
Set increment size INC to <number> and increment.
-<number>
Set increment size INC to -<number> and increment.
*<number>
Increment <number> * INC bytes.
<Enter>
Increment INC bytes.
- Set INC to -INC and increment.
+ Set INC to default (rows * columns) and increment.
# Display current value of INC.
<number>
Go to file offset position <number>.
@<number>
Overwrite bytes starting at position <number>. (Edit mode
only.)
b Binary display (default 8 columns).
B Binary display (default 16 columns).
d Decimal display (default 16 columns).
D Decimal display (default 32 columns).
h Hexadecimal display (default 16 columns).
H Hexadecimal display (default 32 columns).
o Octal display (default 16 columns).
O Octal display (default 32 columns).
c Character display only (default 64 columns).
C Character display only (default 128 columns).
[r].[c]
If r is nonzero, set number of rows to r (range: [1..64]). If c
is nonzero, override column defaults of above alphabetic
commands and set number of columns to c (range [1..128]).
A.[c] Display according to A (=b|B|d|D|h|H|o|O|c|C) and restore
default column settings if c not present or zero; otherwise,
override column defaults and set number of columns to c.
| Toggle between supplemental character display present or absent.
/ Toggle between column labels or no column labels.
! Toggle between compressed or uncompressed numeric display.
<C Mark current position and execute command C.
> Go to previous marked position. (Initial marked position is 0.)
? Display list of commands.
Q Terminate program. (Not case sensitive.)
NOTES
+ Program terminates if it reads past the last byte of the file.
+ To prevent skewing of column labels when reading some files
(e.g. a growing file) pass the program a maximum file size in
the argument to the -r option.
+ Overwriting, command @ (edit mode only), will accept input
according to the current numeric base and will accept character
strings (byte values in the range [32..126]) when no numeric
display is present.
+ Enter "<>" to toggle between two file positions.
+ Files open for writing are also open for reading (see exception
below).
+ The command "." is null.
+ Translate method: fb t[ ]b|d|h|o File1 [File2]
- All characters from "|" to end of line are ignored for input
lines.
- If File1 and File2 are not the same file, File2 is open for
writing only.
- Numbers in input may be delimited by any non-digit for base
2|8|10|16 with the exception of the "|" character. If not
delimited, 8|3|3|2 digits will be converted at a time.
- Example: "fb -als File | fb th File.out" results in File and
File.out having identical contents.
EXIT STATUS
fb returns
1 if an error occurred.
0 if there were no errors
with the exception of the compare method. In this case fb returns, if
there were no errors, either
0 files the same,
2 bytes differ,
3 sizes differ, or
4 bytes and sizes differ.
AUTHOR
John Howard Swaby
polymath@uwyo.edu
VERSION
fb 1.5 (2 May 1999)
SEE ALSO
dd(1), od(1)
2 May 1999 FB(1)