xxd flags & options

Basic usage

Create a hex dump of a file.

xxd file.bin

-p, --plain

Plain hex dump without line numbers or ASCII column.

xxd -p file.bin

-r, --revert

Reverse a hex dump back into binary.

xxd -r hexdump.txt > restored.bin
xxd -r -p plainhex.txt > restored.bin

-l, --len

Dump only the first N bytes.

xxd -l 64 file.bin

-s, --seek

Start at a byte offset.

xxd -s 0x100 file.bin
xxd -s 256 -l 32 file.bin

-c, --cols

Set the number of bytes per line.

xxd -c 32 file.bin

-g, --groupsize

Set byte grouping. Default is 2.

xxd -g 1 file.bin
xxd -g 4 file.bin

-i, --include

Output as a C-style array.

xxd -i data.bin

-b, --bits

Show binary (bits) instead of hex.

xxd -b file.bin

Edit a binary file

Dump, edit the hex, and convert back.

xxd file.bin > hex.txt
xxd -r hex.txt > modified.bin