hexdump
Display file contents in hexadecimal format
TLDR
Print the hexadecimal representation of a file, replacing duplicate lines by *
Display the input offset in hexadecimal and its ASCII representation in two columns
Display the hexadecimal representation of a file, but interpret only a specific number of bytes of the input
Verbose - no suppression by * on duplicate lines
Format output using printf-like format string
SYNOPSIS
hexdump [OPTION]... [+OFFSET] [FILE]...
Display hex/octal/decimal/ASCII dump; use stdin if no FILE or FILE is -.
PARAMETERS
-b, --bits
One-byte octal display
-c, --character
One-byte character display
-C, --canonical
Canonical hex bytes + ASCII display
-d, --decimals
Two-byte unsigned decimal display
-e FORMAT, --format=FORMAT
Use custom format string
-f NAME, --format-file=NAME
Read format string from file
-n LENGTH, --length=LENGTH
Output at most LENGTH bytes
-o, --octals
Two-byte octal display
-s BYTES, --skip=BYTES
Skip BYTES input bytes
-t TYPE,TYPE..., --type=TYPE,TYPE...
Select display types (a,c,d,f,o,s,u,x)
-v, --nosqueeze
No * for repeated lines
-x, --hex-dumps
Two-byte hexadecimal display
--help
Display usage help
--version
Show version info
DESCRIPTION
The hexdump command displays file contents or stdin in customizable human-readable formats like hexadecimal, octal, decimal, or ASCII, ideal for binary analysis, debugging, and reverse engineering.
Default output shows line offsets in hex, data as two-byte little-endian hexadecimal integers with ASCII representation on the right, padding short lines with asterisks. Key options enhance usability: -C for canonical hex bytes + ASCII; -d, -o, -x for decimal, octal, hex words; -c for characters.
Power users employ -e format strings (syntax: [iteration]/[size][skip][format]) for precise control, e.g., '4/4 "%.4f\n"' for floats. -t specifies types like c (char), u (unsigned), f (float). -s skips bytes, -n limits length, -v prevents * squeezing repeats.
Handles multiple files (prefixing output with names) or pipes seamlessly. Essential for forensics, scripting data inspection, or verifying binaries without GUI tools.
CAVEATS
Custom formats (-e, -t) require precise syntax; errors cause misreads. Large files generate huge output without -n. Endianness assumes little-endian by default.
FORMAT STRING SYNTAX
[N]/[S][Z][F]; N=iterations, S=size, F=printf-like specifier (e.g., '16/1 "%.2x" "\n"' for raw hex).
QUICK EXAMPLES
hexdump -C file.bin — Readable hex+ASCII.
hexdump -e '1/1 "%.0f\n"' nums — Dec bytes as ints.
echo 'hello' | hexdump -vC — Stdin canonical dump.
HISTORY
Introduced in 4.2BSD (1983) for binary inspection. Ported to GNU coreutils (~1990s), actively maintained with POSIX compliance enhancements.


