From owner-svn-src-head@freebsd.org Mon Jun 29 15:15:14 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE85334B9F8; Mon, 29 Jun 2020 15:15:14 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49wWJL5VBrz3dmw; Mon, 29 Jun 2020 15:15:14 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A0DB09807; Mon, 29 Jun 2020 15:15:14 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05TFFES6094668; Mon, 29 Jun 2020 15:15:14 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05TFFEdD094667; Mon, 29 Jun 2020 15:15:14 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202006291515.05TFFEdD094667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Mon, 29 Jun 2020 15:15:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362783 - head/usr.bin/hexdump X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/usr.bin/hexdump X-SVN-Commit-Revision: 362783 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jun 2020 15:15:14 -0000 Author: fernape (ports committer) Date: Mon Jun 29 15:15:14 2020 New Revision: 362783 URL: https://svnweb.freebsd.org/changeset/base/362783 Log: hexdump(1): Add EXAMPLES section * Add examples showing the use of -f, -C, -s, -n * Rework the two already present examples that were *format* examples * Remove .Tn suggested by mandoc(1) * Remove reference to gdb(1) since it is not present in current Approved by: manpages (gbe) Differential Revision: https://reviews.freebsd.org/D25406 Modified: head/usr.bin/hexdump/hexdump.1 Modified: head/usr.bin/hexdump/hexdump.1 ============================================================================== --- head/usr.bin/hexdump/hexdump.1 Mon Jun 29 13:30:48 2020 (r362782) +++ head/usr.bin/hexdump/hexdump.1 Mon Jun 29 15:15:14 2020 (r362783) @@ -28,7 +28,7 @@ .\" @(#)hexdump.1 8.2 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd October 29, 2014 +.Dd June 29, 2020 .Dt HEXDUMP 1 .Os .Sh NAME @@ -242,8 +242,7 @@ Output characters in the default character set. Nonprinting characters are displayed as a single .Dq Cm \&. . .It Cm _u -Output US -.Tn ASCII +Output US ASCII characters, with the exception that control characters are displayed using the following, lower-case, names. Characters greater than 0xff, hexadecimal, are displayed as hexadecimal @@ -330,18 +329,59 @@ option. .Sh EXIT STATUS .Ex -std hexdump hd .Sh EXAMPLES -Display the input in perusal format: +Dump input in canonical (hex+ASCII) form: .Bd -literal -offset indent +$ echo "FreeBSD: The power to serve" | hexdump -C +00000000 46 72 65 65 42 53 44 3a 20 54 68 65 20 70 6f 77 |FreeBSD: The pow| +00000010 65 72 20 74 6f 20 73 65 72 76 65 0a |er to serve.| +0000001c +.Ed +.Pp +Same as above but skipping the first 4 bytes of stdin and interpreting only 3 +bytes of input: +.Bd -literal -offset indent +$ echo "FreeBSD: The power to serve" | hexdump -C -s 4 -n 3 +00000004 42 53 44 |BSD| +00000007 +.Ed +.Pp +Assuming a format file named +.Pa format.txt +with the following contents that specify a perusal format: +.Bd -literal -offset indent "%06.6_ao " 12/1 "%3_u " "\et\et" "%_p " "\en" .Ed .Pp -Implement the \-x option: +Dump input in canonical form using the format in +.Pa format.txt : .Bd -literal -offset indent +$ echo "FreeBSD" | hexdump -f format.txt -C +000000 F r e e B S D lf F r e e B S D . +00000000 46 72 65 65 42 53 44 0a |FreeBSD.| +00000008 +.Ed +.Pp +Assuming a format file named +.Pa format.txt +with the following contents that simulate the +.Fl x +option: +.Bd -literal -offset indent "%07.7_Ax\en" "%07.7_ax " 8/2 "%04x " "\en" .Ed +.Pp +Dump input in canonical form using the format in +.Pa format.txt : +.Bd -literal -offset indent +$ echo "FreeBSD: The power to serve" | hexdump -f format.txt -C +0000000 7246 6565 5342 3a44 5420 6568 7020 776f +00000000 46 72 65 65 42 53 44 3a 20 54 68 65 20 70 6f 77 |FreeBSD: The pow| +0000010 7265 7420 206f 6573 7672 0a65 +00000010 65 72 20 74 6f 20 73 65 72 76 65 0a |er to serve.| +0000001c +.Ed .Sh SEE ALSO -.Xr gdb 1 , .Xr od 1