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