fb Home | About | Screen Shot | 7 Examples [ Manual ] Delta from 1.4

fb man page

NAME

fb - binary file viewer, editor, and manipulator

SYNOPSIS

fb [- c|h|n|v] |
   [[-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]

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 INC 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 (a)ppend/(c)opy 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

EXIT STATUS

fb returns

AUTHOR

John Howard Swaby
PolyMath@UWyo.edu

VERSION

fb 1.5 (2 May 1999)