HXASCDMP(1)

NAME
hxascdmp - hexadecimal ASCII dump

SYNOPSIS
hxascdmp [-1] [-2] [-b=BPL] [-h] [-H] [-N] [-o=OFF] [-q] [-V] [FILE+]

DESCRIPTION

This utility reads one or more FILE names and dumps their contents in hexadecimal and ASCII to stdout. If no FILE is given then stdin is read instead; reading continues (or stalls) until an EOF is received. The output is byte oriented, so there are no options for word (2 bytes) or double word (4 bytes) representations.

The default format is to start each line with the hexadecimal address (offset from the start of file) followed by 16 hexadecimal bytes separated by a single space (apart from the 8th and 9th bytes which are separated by two spaces; for improved readability). If the -H is not given, there is then a string of 16 ASCII characters corresponding to the hexadecimal bytes earlier in the line; only bytes in the range 0x20 to 0x7e are printed in ASCII, other bytes values are printed as '.' . If the -H is not given, each FILE name that appears on the command line is printed on a separate line prior to that file's hexadecimal ASCII dump.

If the -N option is given then no address is printed out and each line starts with the next hexadecimal byte.

This utility is pretty close to the 'hexdump -C' variant of BSD's hexdump(1) command. And hexdump is recommended if a word or double word representation is required.

OPTIONS

-1  prints the first byte of FILE in ASCII hexadecimal (i.e. two ASCII characters) then exits. If there are multiple FILEs then the first byte of each file is printed on a separate line. If there are no FILEs then it reads the first byte from stdin, prints it in ASCII hex then exits. To prepend '0x' to the output add the -H option.

-2  prints the first two bytes of FILE in ASCII hexadecimal (i.e. two ASCII hex digits [0-9, a-f], a space character followed by two ASCII hex digits) then exits. If there are multiple FILEs then the first two bytes of each file is printed on a separate line. If there are no FILEs then it reads the first two bytes from stdin, prints them in ASCII hex then exits. To prepend '0x' each hex byte in the output add the -H option.

-b=BPL
    where BPL specifies the number of bytes per line. The default value is 16. 16 bytes per line is just enough to allow the address, 16 bytes in hexadecimal followed by 16 bytes as ASCII to fit on a standard 80 column wide terminal.

-h  output the usage message then exit.

-H  output hexadecimal only (i.e. don't place an ASCII representation at the end of each line).

-N  no address; so each line starts with the next hexadecimal byte.

-o=OFF
    where OFF specifies the byte offset from the beginning of the pipe or the beginning of each file that the output starts. If the address is being printed out then it starts at OFF. The default is an OFF of 0 .

-q  Don't print any file information on the first line.

-V, --version
    print the version string and then exit.

NOTES
In Windows the given file (or files) are set to binary mode.

EXIT STATUS
The exit status of hxascdmp is 0 when it is successful. If any of the given FILE names cannot be opened then the exit status is 1.

EXAMPLES
First we manufacture a short file with a mix of data in it: mostly ASCII with some control characters and 0xaa (which the echo command only accepts in octal (0252):

   $ echo -e "three blind mice, 252" > 3bm.txt

Now we use this utility to see exactly what is in the file. To avoid problems with line wrapping, the bytes per line option is set to 8:

   $ hxascdmp -b=8 3bm.txt
ASCII hex dump of file: 3bm.txt
 00 74 68 72 65 65 20 62 6c three bl
 08 69 6e 64 20 6d 69 63 65 ind mice
 10 2c 09 0d aa 0a ,....

Using the same file, use this utility to output only hexadecimal formatted 16 bytes per line.

   $ hxascdmp -H 3bm.txt
hex dump of file: 3bm.txt
 00 74 68 72 65 65 20 62 6c 69 6e 64 20 6d 69 63 65
 10 2c 09 0d aa 0a

For comparison the hexdump utility gives similar output:

   $ hexdump -C 3bm.txt
00000000 74 68 72 65 65 20 62 6c 69 6e 64 20 6d 69 63 65 |three blind mice|
00000010 2c 09 0d aa 0a |,....|
00000015

To paginate the output, pipe through the more or less command. That way viewing part of a long binary file can be terminated by using 'q' when the more (or less) command pauses after displaying one page of hex.

AUTHORS
Written by Douglas Gilbert.

REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

COPYRIGHT
Copyright © 2004-2026 Douglas Gilbert
This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

SEE ALSO
hexdump(1), less(1), more(1)