Make a hex dump, or convert one back to binary.

Synopsis

xxd [options] [infile [outfile]]

Description

Produces a hex dump of infile (or standard input), or with -r, reverses a hex dump back into binary.

Options

-c cols Number of octets per line (default 16; 30 for -p; 12 for -i).

-g bytes Number of octets per group (default 2; 0 disables grouping).

-l len Stop after len octets.

-s seek Start at seek offset (negative counts from end).

-u Use uppercase hex letters.

-p Output in plain (postscript-style, continuous hex) format.

-i Output in C include style.

-r Reverse: convert a hex dump back to binary (-r -p for plain).

Examples

$ xxd file.bin

Hex-dump a file with offsets and ASCII sidebar.

$ xxd -p file.bin

Plain continuous hex output, no offsets.

$ xxd -r -p hex.txt > file.bin

Convert a plain hex dump back to binary.

See Also

od, strings, base64