Post History
xxd xxd produces a hex dump of the input fed to it. For each byte of input, this includes two hex digits and a symbol which is either an ASCII representation (if the byte corresponds to a printabl...
#1: Initial revision
## `xxd` `xxd` produces a hex dump of the input fed to it. For each byte of input, this includes two hex digits and a symbol which is either an ASCII representation (if the byte corresponds to a printable character) or a `.` character (proxy for non-ASCII bytes). This means it can't understand Unicode, but it also can't emit anything potentially dangerous. (It does have options for colour output, but it fully controls what ANSI codes are produced.) Processing file contents with tools like `cut` is safe in itself; the risk comes from actual output. So for example one can `cut` a file and pipe the result to `xxd`. `xxd` does not page the output, but its output can in turn be piped to a pager. Piping `xxd` output to `head` or `tail` will get a few lines of `xxd`'s formatted output, which may have no correspondence to "lines" in the original file. As an example: ``` $ echo -e '\e[1;31;103mHello\b\b\b\b\bこんにちは\e[0m' | xxd 00000000: 1b5b 313b 3331 3b31 3033 6d48 656c 6c6f .[1;31;103mHello 00000010: 0808 0808 08e3 8193 e382 93e3 81ab e381 ................ 00000020: a1e3 81af 1b5b 306d 0a .....[0m. ``` Without `xxd`, in a Unicode-aware terminal, the `echo` displays the Japanese text (overwriting and hiding the English), in an annoying colour combination.
