Skip to content
Steve Hollasch edited this page Aug 4, 2013 · 2 revisions

hex

Name

hex - Dump file or stream in hexadecimal and ASCII

Synopsis

hex [-?] [-b|w|l|q|o] [-c] [-s<start>] [-e<end>] [file] ... [file]

Description

hex is a filter that reads data from either standard input (if no filenames are supplied) or from the list of files, and dumps the data in hexadecimal and ASCII. Note that options may be prefixed with either a '-' or with a '/' character, and that you can put spaces between the switch letter and the argument (e.g. "-e200" or "-e 200").

To specify hexadecimal values, prefix with "0x". To specify octal values, prefix with "0" (zero). For example, 200 = 0310 = 0xC8.

Options include the following:

-?  Display help information.

-b  Display output grouped by bytes (1 byte / 8 bits)
-w  Display output grouped by words (2 bytes / 16 bits)
-l  Display output grouped by longwords [default] (4 bytes / 32 bits)
-q  Display output grouped by quadwords (8 bytes / 64 bits)
-o  Display output grouped by octwords (16 bytes / 128 bits)

-c  Compact duplicate lines. Blocks of identical data are represented by
    the first line of data, followed by a single line of "====".

-s  Start the dump at the given location (octal, decimal or hex).

-e  End the dump at the given location (octal, decimal or hex).

Important: From the command line, DOS does redirection streams as text, rather than binary. This means that if you want to look at a binary data file, you should probably specify the filename on the command line (e.g. "hex foo.xyz") rather than as a redirection (e.g. "hex <foo.xyz"). In the latter case, a Ctrl-Z character looks like an end-of-file, and your binary files will likely appear much shorter than they really are.

Examples

To dump the contents of file frotz.zzz to screen:

hex frotz.zzz | more

To dump the words from 0x200 to 0x240 for files file1, file2 & file3:

hex -s0x200 -e 0x240 -w file1 file2 file3
Clone this wiki locally