xxd — make a hex dump of a file or of piped text
SYNOPSIS
xxd [-l N] [-c N] [-p] [-u] <file> xxd [options] (dump piped input)
DESCRIPTION
Prints the bytes of a file in hexadecimal. Each row shows the offset of its
first byte (8 hex digits), 16 bytes grouped by two, and the same bytes as
text in a gutter on the right, where anything that is not printable ASCII
appears as a dot. With no file (or -), xxd dumps what is piped into it —
e.g. echo hello | xxd.
Text is dumped as its UTF-8 bytes, so an accented letter takes two bytes and an emoji four.
OPTIONS
-l N stop after N bytes -c N N bytes per row (default 16, or 30 with -p; at most 256) -p plain hex dump: only the hex digits, no offset and no gutter -u use uppercase hex digits
- read standard input (the piped text)
USE CASES
- see the real bytes behind a text: an invisible character, a tab instead of spaces, a non-breaking space, a byte order mark;
- check how a character is encoded in UTF-8: echo é | xxd;
- get the hex form of a short string: echo hello | xxd -p.
NOTES
This xxd only dumps: there is no -r to turn a hex dump back into a file. Piped text is dumped with the newline that ends its last line, as a Unix pipe would deliver it. Nothing leaves your browser.
EXAMPLES
xxd about.md xxd -l 64 about.md echo hello | xxd echo "héllo ✓" | xxd -c 8 echo hello | xxd -p