xxd
Hexadecimal dump and reverse tool
TLDR
Create a hex dump of a file
SYNOPSIS
xxd [options] [infile [outfile]]
DESCRIPTION
xxd creates a hexadecimal dump of a file or standard input. The output shows the offset, hexadecimal values, and ASCII representation of the data. It can also reverse a hex dump back to the original binary.
The default output format shows 16 bytes per line with the file offset, hex values in groups of 2 bytes, and printable ASCII characters. The -p option produces a continuous hex string without formatting.
The -i option generates C source code with the data as an unsigned char array, useful for embedding binary data in programs.
The -r option reverses the process, converting a hex dump back to binary. Combined with -p, it can convert plain hex strings to binary data.
PARAMETERS
-b
Binary digit dump instead of hexadecimal-c cols
Format output with specified columns per line (default: 16)-g bytes
Number of bytes per group (default: 2)-i
Output as C include file (array definition)-l len
Stop after outputting len bytes-p, -ps, -plain
Plain hexdump style (continuous hex without addresses)-r, -revert
Reverse operation: convert hexdump to binary-s seek
Start at specified offset in file-u
Use uppercase hexadecimal letters-e
Little-endian dump (group bytes are reversed)
VIM INTEGRATION
xxd integrates with vim for hex editing. In vim, use :%!xxd to convert buffer to hex dump, edit the hex values, then :%!xxd -r to convert back to binary.
CAVEATS
When using -r, xxd is tolerant of missing or out-of-order lines if the output is seekable. Non-hex characters in the hex column are ignored during revert. The -r option requires properly formatted input matching xxd's output format (or plain hex with -p).
HISTORY
xxd was written by Juergen Weigert and is distributed with vim. It was created as a more versatile alternative to traditional hex dump utilities like od. The tool has been part of the vim distribution since the mid-1990s and is commonly available on Unix-like systems.
