Search code examples
shellunix

Commandline hexdump with ASCII output?


If I hexdump file.txt then I only get the hex vaules.

Would it be possible to show both hex and ASCII in text mode just like a GUI hex editor?


Solution

  • hexdump -C does what you want.

    # hexdump -C /etc/passwd
    00000000  72 6f 6f 74 3a 78 3a 30  3a 30 3a 72 6f 6f 74 3a  |root:x:0:0:root:|
    00000010  2f 72 6f 6f 74 3a 2f 62  69 6e 2f 62 61 73 68 0a  |/root:/bin/bash.|
    00000020  64 61 65 6d 6f 6e 3a 78  3a 31 3a 31 3a 64 61 65  |daemon:x:1:1:dae|
    00000030  6d 6f 6e 3a 2f 75 73 72  2f 73 62 69 6e 3a 2f 62  |mon:/usr/sbin:/b|
    00000040  69 6e 2f 73 68 0a 62 69  6e 3a 78 3a 32 3a 32 3a  |in/sh.bin:x:2:2:|
    00000050  62 69 6e 3a 2f 62 69 6e  3a 2f 62 69 6e 2f 73 68  |bin:/bin:/bin/sh|
    ...