Section: User Commands (1)
Updated: 2 May 1999
Return to Main Contents
binhex - binary file viewer, editor, and manipulator
[[-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] |
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.
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,
has a hexadecimal numeric display along with a character display.
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
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.
- Base options:
Binary numbers (8 columns).
Binary numbers (16 columns).
Decimal numbers (16 columns).
Decimal numbers (32 columns).
Hexadecimal numbers (16 columns).
Hexadecimal numbers (32 columns).
Octal numbers (16 columns).
Octal numbers (32 columns).
- Display options:
Suppress offset addresses.
(Ignored if effective mode is interactive.)
Display offset addresses.
Characters only (64 columns).
Characters only (128 columns).
Numeric display is compressed (no spaces between numbers).
Numeric display is not compressed (spaces between numbers).
Suppress column labels.
Display column labels.
Exclude supplemental character display.
Include supplemental character display.
- Mode options:
Edit mode. (Ignored if effective mode is non-interactive.)
Stream output (non-interactive mode).
Interactive mode. (Will nullify previous -s or -t options.)
Read from standard input and stream output (non-interactive
mode). (Will nullify previous -S or -T options.) Note: File
name MUST be "-".
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.
Options are evaluated left-to-right. When options
are mutually exclusive, only last one is effective.
- binhex File
is the same as
binhex -hAEKLNST -p . -r . -i 0 File
- Append and Copy methods:
- binhex a RNG File1 [File2]
- binhex 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:
- binhex 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:
- binhex 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:
- binhex 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.
- - c
List interactive commands.
- - h
Display help page.
- - n
Display notes concerning
- - v
Show current version information.
Note: A space MUST be present between "-" and either c, h, n, or v.
Set increment size INC to <number> and increment.
Set increment size INC to -<number> and increment.
Increment <number> * INC bytes.
Increment INC bytes.
Set INC to -INC and increment.
Set INC to default (rows * columns) and increment.
Display current value of INC.
Go to file offset position <number>.
Overwrite bytes starting at position <number>. (Edit mode only.)
Binary display (default 8 columns).
Binary display (default 16 columns).
Decimal display (default 16 columns).
Decimal display (default 32 columns).
Hexadecimal display (default 16 columns).
Hexadecimal display (default 32 columns).
Octal display (default 16 columns).
Octal display (default 32 columns).
Character display only (default 64 columns).
Character display only (default 128 columns).
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]).
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.
Mark current position and execute command C.
Go to previous marked position. (Initial marked position is 0.)
Display list of commands.
Terminate program. (Not case sensitive.)
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: binhex 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: "binhex -als File | binhex th File.out" results in File and File.out
having identical contents.
if an error occurred.
if there were no errors
with the exception of the compare method. In this case
returns, if there were no errors, either
files the same,
sizes differ, or
bytes and sizes differ.
John Howard Swaby
1.5 (2 May 1999)
- EXIT STATUS
- SEE ALSO
linux.jgfs.net manual pages