Add '-C' "Canonical" format to hexdump:

$ hexdump -C /etc/resolv.conf
00000000 64 6f 6d 61 69 6e 20 64 6b 2e 74 66 73 2e 63 6f |domain dk.tfs.co|
00000010 6d 0a 6e 61 6d 65 73 65 72 76 65 72 20 31 34 30 |m.nameserver 140|
00000020 2e 31 34 35 2e 32 33 30 2e 31 30 0a             |.145.230.10.|
This commit is contained in:
phk 1996-09-16 21:18:48 +00:00
parent 9302e8033e
commit 398743f65b
2 changed files with 12 additions and 2 deletions

View File

@ -39,7 +39,7 @@
.Nd ascii, decimal, hexadecimal, octal dump
.Sh SYNOPSIS
.Nm hexdump
.Op Fl bcdovx
.Op Fl bcCdovx
.Op Fl e Ar format_string
.Op Fl f Ar format_file
.Op Fl n Ar length
@ -64,6 +64,11 @@ in octal, per line.
Display the input offset in hexadecimal, followed by sixteen
space-separated, three column, space-filled, characters of input
data per line.
.It Fl C
.Em 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 ``|'' characters.
.It Fl d
.Em Two-byte decimal display.
Display the input offset in hexadecimal, followed by eight

View File

@ -56,7 +56,7 @@ newsyntax(argc, argvp)
char *p, **argv;
argv = *argvp;
while ((ch = getopt(argc, argv, "bcde:f:n:os:vx")) != EOF)
while ((ch = getopt(argc, argv, "bcCde:f:n:os:vx")) != EOF)
switch (ch) {
case 'b':
add("\"%07.7_Ax\n\"");
@ -66,6 +66,11 @@ newsyntax(argc, argvp)
add("\"%07.7_Ax\n\"");
add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"");
break;
case 'C':
add("\"%08.8_Ax\n\"");
add("\"%08.8_ax \" 16/1 \"%02x \" ");
add("\" |\" 16/1 \"%_p\" \"|\\n\"");
break;
case 'd':
add("\"%07.7_Ax\n\"");
add("\"%07.7_ax \" 8/2 \" %05u \" \"\\n\"");