1. Technology
Linux / Unix Command: xxd
Command Library

NAME

xxd - make a hexdump or do the reverse.  

SYNOPSIS

xxd -h[elp]
xxd [options] [infile [outfile]]
xxd -r[evert] [options] [infile [outfile]]  

DESCRIPTION

xxd creates a hex dump of a given file or standard input. It can also convert a hex dump back to its original binary form. Like uuencode(1) and uudecode(1) it allows the transmission of binary data in a `mail-safe' ASCII representation, but has the advantage of decoding to standard output. Moreover, it can be used to perform binary file patching.  

OPTIONS

If no infile is given, standard input is read. If infile is specified as a `-' character, then input is taken from standard input. If no outfile is given (or a `-' character is in its place), results are sent to standard output.

Note that a "lazy" parser is used which does not check for more than the first option letter, unless the option is followed by a parameter. Spaces between a single option letter and its parameter are optional. Parameters to options can be specified in decimal, hexadecimal or octal notation. Thus -c8, -c 8, -c 010 and -cols 8 are all equivalent.

-a | -autoskip
toggle autoskip: A single '*' replaces nul-lines. Default off.
-b | -bits
Switch to bits (binary digits) dump, rather than hexdump. This option writes octets as eight digits "1"s and "0"s instead of a normal hexacecimal dump. Each line is preceded by a line number in hexadecimal and followed by an ascii (or ebcdic) representation. The command line switches -r, -p, -i do not work with this mode.
-c cols | -cols cols
-c cols | -cols cols format <cols> octets per line. Default 16 (-i: 12, -ps: 30, -b: 6). Max 256.
-E | -EBCDIC
Change the character encoding in the righthand column from ASCII to EBCDIC. This does not change the hexadecimal representation. The option is meaningless in combinations with -r, -p or -i.
-g bytes | -groupsize bytes
seperate the output of every <bytes> bytes (two hex characters or eight bit-digits each) by a whitespace. Specify -g 0 to suppress grouping. <Bytes> defaults to 2 in normal mode and 1 in bits mode. Grouping does not apply to postscript or include style.
-h | -help
print a summary of available commands and exit. No hex dumping is performed.
-i | -include
output in C include file style. A complete static array definition is written (named after the input file), unless xxd reads from stdin.
-l len | -len len
stop after writing <len> octets.
-p | -ps | -postscript | -plain
output in postscript continuous hexdump style. Also known as plain hexdump style.
-r | -revert
reverse operation: convert (or patch) hexdump into binary. If not writing to stdout, xxd writes into its output file without truncating it. Use the combination -r -p to read plain hexadecimal dumps without line number information and without a particular column layout. Additional Whitespace and line-breaks are allowed anywhere.
-seek offset
When used after -r : revert with <offset> added to file positions found in hexdump.
-s [+][-]seek
start at <seek> bytes abs. (or rel.) infile offset. + indicates that the seek is relative to the current stdin file position (meaningless when not reading from stdin). - indicates that the seek should be that many characters from the end of the input (or if combined with + : before the current stdin file position). Without -s option, xxd starts at the current file position.
-u
use upper case hex letters. Default is lower case.
-v | -version
show version string.
 

SEE ALSO

uuencode(1), uudecode(1), patch(1)
 

WARNINGS

The tools weirdness matches its creators brain. Use entirely at your own risk. Copy files. Trace it. Become a wizard.
 

Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux/Unix Command Library

>> Shell Command Library

You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

©2014 About.com. All rights reserved.