1HEXDUMP(1) BSD General Commands Manual HEXDUMP(1)
2
4 hexdump — ascii, decimal, hexadecimal, octal dump
5
7 hexdump [-bcCdovx] [-e format_string] [-f format_file] [-n length]
8 [-s skip] file ...
9
11 The hexdump utility is a filter which displays the specified files, or
12 the standard input, if no files are specified, in a user specified for‐
13 mat.
14
15 The options are as follows:
16
17 -b One-byte octal display. Display the input offset in hexadec‐
18 imal, followed by sixteen space-separated, three column,
19 zero-filled, bytes of input data, in octal, per line.
20
21 -c One-byte character display. Display the input offset in
22 hexadecimal, followed by sixteen space-separated, three col‐
23 umn, space-filled, characters of input data per line.
24
25 -C Canonical hex+ASCII display. Display the input offset in
26 hexadecimal, followed by sixteen space-separated, two column,
27 hexadecimal bytes, followed by the same sixteen bytes in %_p
28 format enclosed in ``|'' characters.
29
30 -d Two-byte decimal display. Display the input offset in hexa‐
31 decimal, followed by eight space-separated, five column,
32 zero-filled, two-byte units of input data, in unsigned deci‐
33 mal, per line.
34
35 -e format_string
36 Specify a format string to be used for displaying data.
37
38 -f format_file
39 Specify a file that contains one or more newline separated
40 format strings. Empty lines and lines whose first non-blank
41 character is a hash mark (#) are ignored.
42
43 -n length Interpret only length bytes of input.
44
45 -o Two-byte octal display. Display the input offset in hexadec‐
46 imal, followed by eight space-separated, six column, zero-
47 filled, two byte quantities of input data, in octal, per
48 line.
49
50 -s offset Skip offset bytes from the beginning of the input. By
51 default, offset is interpreted as a decimal number. With a
52 leading 0x or 0X, offset is interpreted as a hexadecimal num‐
53 ber, otherwise, with a leading 0, offset is interpreted as an
54 octal number. Appending the character b, k, or m to offset
55 causes it to be interpreted as a multiple of 512, 1024, or
56 1048576, respectively.
57
58 -v The -v option causes hexdump to display all input data.
59 Without the -v option, any number of groups of output lines,
60 which would be identical to the immediately preceding group
61 of output lines (except for the input offsets), are replaced
62 with a line comprised of a single asterisk.
63
64 -x Two-byte hexadecimal display. Display the input offset in
65 hexadecimal, followed by eight, space separated, four column,
66 zero-filled, two-byte quantities of input data, in hexadeci‐
67 mal, per line.
68
69 For each input file, hexdump sequentially copies the input to standard
70 output, transforming the data according to the format strings specified
71 by the -e and -f options, in the order that they were specified.
72
73 Formats
74 A format string contains any number of format units, separated by white‐
75 space. A format unit contains up to three items: an iteration count, a
76 byte count, and a format.
77
78 The iteration count is an optional positive integer, which defaults to
79 one. Each format is applied iteration count times.
80
81 The byte count is an optional positive integer. If specified it defines
82 the number of bytes to be interpreted by each iteration of the format.
83
84 If an iteration count and/or a byte count is specified, a single slash
85 must be placed after the iteration count and/or before the byte count to
86 disambiguate them. Any whitespace before or after the slash is ignored.
87
88 The format is required and must be surrounded by double quote (" ")
89 marks. It is interpreted as a fprintf-style format string (see
90 fprintf(3)), with the following exceptions:
91
92 · An asterisk (*) may not be used as a field width or precision.
93
94 · A byte count or field precision is required for each ``s'' con‐
95 version character (unlike the fprintf(3) default which prints
96 the entire string if the precision is unspecified).
97
98 · The conversion characters ``h'', ``l'', ``n'', ``p'' and ``q''
99 are not supported.
100
101 · The single character escape sequences described in the C stan‐
102 dard are supported:
103
104 NUL \0
105 <alert character> \a
106 <backspace> \b
107 <form-feed> \f
108 <newline> \n
109 <carriage return> \r
110 <tab> \t
111 <vertical tab> \v
112
113 Hexdump also supports the following additional conversion strings:
114
115 _a[dox] Display the input offset, cumulative across input files, of
116 the next byte to be displayed. The appended characters d, o,
117 and x specify the display base as decimal, octal or hexadeci‐
118 mal respectively.
119
120 _A[dox] Identical to the _a conversion string except that it is only
121 performed once, when all of the input data has been pro‐
122 cessed.
123
124 _c Output characters in the default character set. Nonprinting
125 characters are displayed in three character, zero-padded
126 octal, except for those representable by standard escape
127 notation (see above), which are displayed as two character
128 strings.
129
130 _p Output characters in the default character set. Nonprinting
131 characters are displayed as a single “.”.
132
133 _u Output US ASCII characters, with the exception that control
134 characters are displayed using the following, lower-case,
135 names. Characters greater than 0xff, hexadecimal, are dis‐
136 played as hexadecimal strings.
137
138 000 nul 001 soh 002 stx 003 etx 004 eot 005 enq
139 006 ack 007 bel 008 bs 009 ht 00A lf 00B vt
140 00C ff 00D cr 00E so 00F si 010 dle 011 dc1
141 012 dc2 013 dc3 014 dc4 015 nak 016 syn 017 etb
142 018 can 019 em 01A sub 01B esc 01C fs 01D gs
143 01E rs 01F us 0FF del
144
145 The default and supported byte counts for the conversion characters are
146 as follows:
147
148 %_c, %_p, %_u, %c One byte counts only.
149
150 %d, %i, %o, %u, %X, %x Four byte default, one, two and four byte
151 counts supported.
152
153 %E, %e, %f, %G, %g Eight byte default, four byte counts sup‐
154 ported.
155
156 The amount of data interpreted by each format string is the sum of the
157 data required by each format unit, which is the iteration count times the
158 byte count, or the iteration count times the number of bytes required by
159 the format if the byte count is not specified.
160
161 The input is manipulated in ``blocks'', where a block is defined as the
162 largest amount of data specified by any format string. Format strings
163 interpreting less than an input block's worth of data, whose last format
164 unit both interprets some number of bytes and does not have a specified
165 iteration count, have the iteration count incremented until the entire
166 input block has been processed or there is not enough data remaining in
167 the block to satisfy the format string.
168
169 If, either as a result of user specification or hexdump modifying the
170 iteration count as described above, an iteration count is greater than
171 one, no trailing whitespace characters are output during the last itera‐
172 tion.
173
174 It is an error to specify a byte count as well as multiple conversion
175 characters or strings unless all but one of the conversion characters or
176 strings is _a or _A.
177
178 If, as a result of the specification of the -n option or end-of-file
179 being reached, input data only partially satisfies a format string, the
180 input block is zero-padded sufficiently to display all available data
181 (i.e. any format units overlapping the end of data will display some num‐
182 ber of the zero bytes).
183
184 Further output by such format strings is replaced by an equivalent number
185 of spaces. An equivalent number of spaces is defined as the number of
186 spaces output by an s conversion character with the same field width and
187 precision as the original conversion character or conversion string but
188 with any “+”, “ ”, “#” conversion flag characters removed, and referenc‐
189 ing a NULL string.
190
191 If no format strings are specified, the default display is equivalent to
192 specifying the -x option.
193
194 hexdump exits 0 on success and >0 if an error occurred.
195
197 Display the input in perusal format:
198
199 "%06.6_ao " 12/1 "%3_u "
200 "\t\t" "%_p "
201 "\n"
202
203 Implement the -x option:
204
205 "%07.7_Ax\n"
206 "%07.7_ax " 8/2 "%04x " "\n"
207
209 The hexdump utility is expected to be IEEE Std 1003.2 (“POSIX.2”) compat‐
210 ible.
211
213 The hexdump command is part of the util-linux-ng package and is available
214 from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
215
216BSD April 18, 1994 BSD