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
| Name | Type | Description |
|---|---|---|
| -g BYTES | option | Bytes per displayed group |
| -l LENGTH | option | Limit bytes read |
| -p | option | Plain hexadecimal output |
| -r | option | Reverse conversion |
| INFILE | operand | Default stdin |
| OUTFILE | operand | Default 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