summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-09-16 21:18:48 +0000
committerphk <phk@FreeBSD.org>1996-09-16 21:18:48 +0000
commit132596c18dbc522d87913d68a5bbdf8975a6cbe7 (patch)
treed0cf89aa45262ae4dda8032e00df100613b427ef /usr.bin
parent2bff3824c7715f16db03b89a258bd056842ebc03 (diff)
downloadFreeBSD-src-132596c18dbc522d87913d68a5bbdf8975a6cbe7.zip
FreeBSD-src-132596c18dbc522d87913d68a5bbdf8975a6cbe7.tar.gz
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.|
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/hexdump/hexdump.17
-rw-r--r--usr.bin/hexdump/hexsyntax.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/hexdump/hexdump.1 b/usr.bin/hexdump/hexdump.1
index 321151e..563edac 100644
--- a/usr.bin/hexdump/hexdump.1
+++ b/usr.bin/hexdump/hexdump.1
@@ -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
diff --git a/usr.bin/hexdump/hexsyntax.c b/usr.bin/hexdump/hexsyntax.c
index 68abbe6..829a6303f 100644
--- a/usr.bin/hexdump/hexsyntax.c
+++ b/usr.bin/hexdump/hexsyntax.c
@@ -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\"");
OpenPOWER on IntegriCloud