hexdump
supports specifying a format string via the -e
command-line option, and it seems to be pretty flexible.
Example:
$ hexdump -C b.c
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.|
00000010 68 3e 0a 69 6e 74 20 6d 61 69 6e 28 29 7b 0a 20 |h>.int main(){. |
00000020 20 70 72 69 6e 74 66 28 22 68 65 6c 6c 6f 20 77 | printf("hello w|
00000030 6f 72 6c 64 5c 6e 22 29 3b 0a 20 20 72 65 74 75 |orld\n");. retu|
00000040 72 6e 20 30 3b 0a 7d 0a |rn 0;.}.|
00000048
$ hexdump -e'"%07.8_ax " 8/1 "%02x " " " 8/1 "%02x " " |"' -e'16/1 "%_p" "|\n"' b.c
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.|
00000010 68 3e 0a 69 6e 74 20 6d 61 69 6e 28 29 7b 0a 20 |h>.int main(){. |
00000020 20 70 72 69 6e 74 66 28 22 68 65 6c 6c 6f 20 77 | printf("hello w|
00000030 6f 72 6c 64 5c 6e 22 29 3b 0a 20 20 72 65 74 75 |orld\n");. retu|
00000040 72 6e 20 30 3b 0a 7d 0a |rn 0;.}.|
$ hexdump -e'"%07.8_ad " 8/1 "%03d " " " 8/1 "%03d " " |"' -e'16/1 "%_p" "|\n"' b.c
00000000 035 105 110 099 108 117 100 101 032 060 115 116 100 105 111 046 |#include <stdio.|
00000016 104 062 010 105 110 116 032 109 097 105 110 040 041 123 010 032 |h>.int main(){. |
00000032 032 112 114 105 110 116 102 040 034 104 101 108 108 111 032 119 | printf("hello w|
00000048 111 114 108 100 092 110 034 041 059 010 032 032 114 101 116 117 |orld\n");. retu|
00000064 114 110 032 048 059 010 125 010 |rn 0;.}.|
Not sure about how to reproduce that last line produced by -C
.
See here for more details.
-e '"%07.8_Ad\n"'
. – Lupercalia