Commandline hexdump with ASCII output? [closed]
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|
...
The vim
editor usually (?) includes the tool xxd
.
$ xxd `which xxd` | head -n 10
0000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............
0000010: 0200 3e00 0100 0000 400a 4000 0000 0000 ..>.....@.@.....
0000020: 4000 0000 0000 0000 f035 0000 0000 0000 @........5......
0000030: 0000 0000 4000 3800 0800 4000 1b00 1a00 [email protected]...@.....
0000040: 0600 0000 0500 0000 4000 0000 0000 0000 ........@.......
0000050: 4000 4000 0000 0000 4000 4000 0000 0000 @.@.....@.@.....
0000060: c001 0000 0000 0000 c001 0000 0000 0000 ................
0000070: 0800 0000 0000 0000 0300 0000 0400 0000 ................
0000080: 0002 0000 0000 0000 0002 4000 0000 0000 ..........@.....
0000090: 0002 4000 0000 0000 1c00 0000 0000 0000 ..@.............
hexdump
itself will show both hex and ascii side-by-side:
$ date | hexdump -v -C
00000000 54 68 75 20 4d 61 79 20 20 31 20 31 36 3a 30 30 |Thu May 1 16:00|
00000010 3a 32 35 20 50 44 54 20 32 30 31 34 0a |:25 PDT 2014.|
0000001d
man hexdump
explains:
-C Canonical hex+ASCII display. Display the input offset in hexadecimal, followed by sixteen space-separated, two column, hexadecimal bytes, followed by the same sixteen bytes in %_p format enclosed in ``|'' charac‐ ters. Calling the command hd implies this option.