Skip to content
Latchkey

od: Octal and Hex Dump for Debugging Bytes

od dumps a file in octal, hex, decimal, or ASCII so you can inspect non-printable bytes.

od is in coreutils, so it is present even on images that lack xxd. It is the portable way to reveal a trailing NUL, a CR, or a non-breaking space that breaks a parser.

What it does

od reads a file and prints its bytes in a chosen format. -c shows characters with C escapes (so \r, \n, \0 are visible), and -A x -t x1z gives an xxd-like hex-plus-ASCII view. It is the coreutils fallback when xxd is not installed.

Common usage

Terminal
# show characters with escapes: reveals \r, \0, etc.
od -c file.txt
# xxd-style hex dump with ASCII column
od -A x -t x1z file.bin | head
# single column of one byte per line in hex
od -A n -t x1 -v file.bin
# spot a trailing carriage return
printf 'line\r\n' | od -c

Options

FlagWhat it does
-cPrint characters, showing C-style escapes
-A x|d|o|nAddress (offset) radix: hex, decimal, octal, or none
-t x1Type: hex, 1 byte per unit (x1z adds ASCII column)
-t o1Octal, 1 byte per unit (the classic default is o2)
-vDo not collapse repeated lines into a single "*"
-N <len>Read at most len bytes
-j <off>Skip to byte offset before dumping

In CI

Pass -v when comparing dumps in a test: without it, od replaces runs of identical lines with a *, and two files that differ only inside a collapsed run can look identical. od -An -tx1 -v file | tr -d " \n" produces a bare hex string you can diff or hash.

Common errors in CI

The most common surprise is not an error but the * line: repeated rows are collapsed unless you add -v, which hides differences. Old scripts using GNU-only -tx1z fail on BusyBox od (Alpine), which supports a smaller option set; on Alpine use od -A x -t x1 or install coreutils. Remember offsets from -A x are hex, so a "byte 0x100" is decimal 256.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →