commands

xxd — Convert bytes to hexadecimal

Render binary input as hexadecimal, or with -r reverse a compatible dump. Plain mode (-p) is useful for compact hex; -g changes grouping in the normal dump, and -l limits input length. Reverse mode is permissive and may patch existing output files; do not treat it as strict validation or point it at valuable data. Use stdout or a new private file.

Formal Syntax & Structure

linux syntaxlinux
xxd [-g BYTES] [-l LENGTH] [-p] [INFILE [OUTFILE]]

Parameters & Attributes

NameTypeDescription
-g BYTESoptionBytes per displayed group
-l LENGTHoptionLimit bytes read
-poptionPlain hexadecimal output
-roptionReverse conversion
INFILEoperandDefault stdin
OUTFILEoperandDefault stdout

Return Value

exit status and output

Hexadecimal text or decoded bytes; zero on success, nonzero on reported error. Reverse conversion does not reliably reject all malformed input.

Working Example

Example Snippetlinux
printf 'ABC' | xxd -p
Linux Reference