1 .\" Copyright (c) 1989, 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)hexdump.1 8.2 (Berkeley) 4/18/94
36 .Nd ASCII, decimal, hexadecimal, octal dump
40 .Op Fl e Ar format_string
41 .Op Fl f Ar format_file
49 .Op Fl e Ar format_string
50 .Op Fl f Ar format_file
59 utility is a filter which displays the specified files, or
60 the standard input, if no files are specified, in a user specified
63 The options are as follows:
64 .Bl -tag -width indent
66 .Em One-byte octal display .
67 Display the input offset in hexadecimal, followed by sixteen
68 space-separated, three column, zero-filled, bytes of input data,
71 .Em One-byte character display .
72 Display the input offset in hexadecimal, followed by sixteen
73 space-separated, three column, space-filled, characters of input
76 .Em Canonical hex+ASCII display .
77 Display the input offset in hexadecimal, followed by sixteen
78 space-separated, two column, hexadecimal bytes, followed by the
79 same sixteen bytes in %_p format enclosed in ``|'' characters.
85 .Em Two-byte decimal display .
86 Display the input offset in hexadecimal, followed by eight
87 space-separated, five column, zero-filled, two-byte units
88 of input data, in unsigned decimal, per line.
89 .It Fl e Ar format_string
90 Specify a format string to be used for displaying data.
91 .It Fl f Ar format_file
92 Specify a file that contains one or more newline separated format strings.
93 Empty lines and lines whose first non-blank character is a hash mark
101 .Em Two-byte octal display .
102 Display the input offset in hexadecimal, followed by eight
103 space-separated, six column, zero-filled, two byte quantities of
104 input data, in octal, per line.
108 bytes from the beginning of the input.
111 is interpreted as a decimal number.
117 is interpreted as a hexadecimal number,
118 otherwise, with a leading
121 is interpreted as an octal number.
122 Appending the character
129 causes it to be interpreted as a multiple of
138 to display all input data.
141 option, any number of groups of output lines, which would be
142 identical to the immediately preceding group of output lines (except
143 for the input offsets), are replaced with a line comprised of a
146 .Em Two-byte hexadecimal display .
147 Display the input offset in hexadecimal, followed by eight, space
148 separated, four column, zero-filled, two-byte quantities of input
149 data, in hexadecimal, per line.
154 sequentially copies the input to standard output, transforming the
155 data according to the format strings specified by the
159 options, in the order that they were specified.
161 A format string contains any number of format units, separated by
163 A format unit contains up to three items: an iteration count, a byte
166 The iteration count is an optional positive integer, which defaults to
168 Each format is applied iteration count times.
170 The byte count is an optional positive integer.
171 If specified it defines the number of bytes to be interpreted by
172 each iteration of the format.
174 If an iteration count and/or a byte count is specified, a single slash
175 must be placed after the iteration count and/or before the byte count
176 to disambiguate them.
177 Any whitespace before or after the slash is ignored.
179 The format is required and must be surrounded by double quote
181 It is interpreted as a fprintf-style format string (see
184 following exceptions:
185 .Bl -bullet -offset indent
187 An asterisk (*) may not be used as a field width or precision.
189 A byte count or field precision
191 required for each ``s'' conversion
192 character (unlike the
194 default which prints the entire string if the precision is unspecified).
196 The conversion characters ``h'', ``l'', ``n'', ``p'' and ``q'' are
199 The single character escape sequences
200 described in the C standard are supported:
201 .Bd -ragged -offset indent -compact
202 .Bl -column <alert_character>
204 .It "<alert character> \ea"
205 .It "<backspace> \eb"
206 .It "<form-feed> \ef"
208 .It "<carriage return> \er"
210 .It "<vertical tab> \ev"
217 utility also supports the following additional conversion strings:
219 .It Cm \&_a Ns Op Cm dox
220 Display the input offset, cumulative across input files, of the
221 next byte to be displayed.
222 The appended characters
227 specify the display base
228 as decimal, octal or hexadecimal respectively.
229 .It Cm \&_A Ns Op Cm dox
232 conversion string except that it is only performed
233 once, when all of the input data has been processed.
235 Output characters in the default character set.
236 Nonprinting characters are displayed in three character, zero-padded
237 octal, except for those representable by standard escape notation
239 which are displayed as two character strings.
241 Output characters in the default character set.
242 Nonprinting characters are displayed as a single
247 characters, with the exception that control characters are
248 displayed using the following, lower-case, names.
249 Characters greater than 0xff, hexadecimal, are displayed as hexadecimal
251 .Bl -column 000_nu 001_so 002_st 003_et 004_eo
252 .It "000 NUL" Ta "001 SOH" Ta "002 STX" Ta "003 ETX" Ta "004 EOT" Ta "005 ENQ"
253 .It "006 ACK" Ta "007 BEL" Ta "008 BS" Ta "009 HT" Ta "00A LF" Ta "00B VT"
254 .It "00C FF" Ta "00D CR" Ta "00E\ SO" Ta "00F SI" Ta "010 DLE" Ta "011 DC1"
255 .It "012 DC2" Ta "013 DC3" Ta "014 DC4" Ta "015\ NAK" Ta "016 SYN" Ta "017 ETB"
256 .It "018 CAN" Ta "019 EM" Ta "01A SUB" Ta "01B ESC" Ta "01C FS" Ta "01D GS"
257 .It "01E RS" Ta "01F US" Ta "07F DEL" Ta \& Ta \& Ta \&
261 The default and supported byte counts for the conversion characters
263 .Bl -tag -width "Xc,_Xc,_Xc,_Xc,_Xc,_Xc" -offset indent
264 .It Li \&%_c , \&%_p , \&%_u , \&%c
265 One byte counts only.
267 .Li \&%d , \&%i , \&%o ,
268 .Li \&%u , \&%X , \&%x
270 Four byte default, one, two and four byte counts supported.
272 .Li \&%E , \&%e , \&%f ,
275 Eight byte default, four and twelve byte counts supported.
278 The amount of data interpreted by each format string is the sum of the
279 data required by each format unit, which is the iteration count times the
280 byte count, or the iteration count times the number of bytes required by
281 the format if the byte count is not specified.
283 The input is manipulated in ``blocks'', where a block is defined as the
284 largest amount of data specified by any format string.
285 Format strings interpreting less than an input block's worth of data,
286 whose last format unit both interprets some number of bytes and does
287 not have a specified iteration count, have the iteration count
288 incremented until the entire input block has been processed or there
289 is not enough data remaining in the block to satisfy the format string.
291 If, either as a result of user specification or
294 the iteration count as described above, an iteration count is
295 greater than one, no trailing whitespace characters are output
296 during the last iteration.
298 It is an error to specify a byte count as well as multiple conversion
299 characters or strings unless all but one of the conversion characters
305 If, as a result of the specification of the
307 option or end-of-file being reached, input data only partially
308 satisfies a format string, the input block is zero-padded sufficiently
309 to display all available data (i.e., any format units overlapping the
310 end of data will display some number of the zero bytes).
312 Further output by such format strings is replaced by an equivalent
314 An equivalent number of spaces is defined as the number of spaces
317 conversion character with the same field width
318 and precision as the original conversion character or conversion
323 conversion flag characters
324 removed, and referencing a NULL string.
326 If no format strings are specified, the default display is equivalent
333 Display the input in perusal format:
334 .Bd -literal -offset indent
335 "%06.6_ao " 12/1 "%3_u "
340 Implement the \-x option:
341 .Bd -literal -offset indent
343 "%07.7_ax " 8/2 "%04x " "\en"