1HEXDUMP(1)                       User Commands                      HEXDUMP(1)
2
3
4

NAME

6       hexdump  -  display  file  contents  in hexadecimal, decimal, octal, or
7       ascii
8

SYNOPSIS

10       hexdump [options] file...
11

DESCRIPTION

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

OPTIONS

17       Below,  the  length  and offset arguments may be followed by the multi‐
18       plicative suffixes KiB (=1024), MiB (=1024*1024), and so  on  for  GiB,
19       TiB,  PiB,  EiB,  ZiB  and YiB (the "iB" is optional, e.g., "K" has the
20       same meaning as "KiB"), or the suffixes KB  (=1000),  MB  (=1000*1000),
21       and so on for GB, TB, PB, EB, ZB and YB.
22
23       -b, --one-byte-octal
24              One-byte  octal  display.  Display the input offset in hexadeci‐
25              mal, followed by sixteen  space-separated,  three-column,  zero-
26              filled bytes of input data, in octal, per line.
27
28       -c, --one-byte-char
29              One-byte  character  display.  Display the input offset in hexa‐
30              decimal,  followed  by  sixteen  space-separated,  three-column,
31              space-filled characters of input data per line.
32
33       -C, --canonical
34              Canonical  hex+ASCII display.  Display the input offset in hexa‐
35              decimal, followed by sixteen space-separated, two-column,  hexa‐
36              decimal  bytes, followed by the same sixteen bytes in %_p format
37              enclosed in '|' characters.
38
39       -d, --two-bytes-decimal
40              Two-byte decimal display.  Display the input offset in hexadeci‐
41              mal,  followed  by  eight  space-separated,  five-column,  zero-
42              filled, two-byte units of input data, in unsigned  decimal,  per
43              line.
44
45       -e, --format format_string
46              Specify a format string to be used for displaying data.
47
48       -f, --format-file file
49              Specify  a file that contains one or more newline-separated for‐
50              mat strings.  Empty lines and lines whose first non-blank  char‐
51              acter is a hash mark (#) are ignored.
52
53       -L, --color[=when]
54              Accept  color  units for the output.  The optional argument when
55              can be auto, never or always.  If the when argument is  omitted,
56              it  defaults  to auto.  The colors can be disabled; for the cur‐
57              rent built-in default see the --help output.  See also the  Col‐
58              ors subsection and the COLORS section below.
59
60       -n, --length length
61              Interpret only length bytes of input.
62
63       -o, --two-bytes-octal
64              Two-byte  octal  display.  Display the input offset in hexadeci‐
65              mal, followed by eight space-separated, six-column, zero-filled,
66              two-byte quantities of input data, in octal, per line.
67
68       -s, --skip offset
69              Skip offset bytes from the beginning of the input.
70
71       -v, --no-squeezing
72              The -v option causes hexdump to display all input data.  Without
73              the -v option, any number of groups of output lines which  would
74              be  identical to the immediately preceding group of output lines
75              (except for the input offsets), are replaced with  a  line  com‐
76              prised of a single asterisk.
77
78       -x, --two-bytes-hex
79              Two-byte hexadecimal display.  Display the input offset in hexa‐
80              decimal, followed by eight space-separated,  four-column,  zero-
81              filled,  two-byte  quantities of input data, in hexadecimal, per
82              line.
83
84       -V, --version
85              Display version information and exit.
86
87       -h, --help
88              Display help text and exit.
89
90       For each input file, hexdump sequentially copies the input to  standard
91       output, transforming the data according to the format strings specified
92       by the -e and -f options, in the order that they were specified.
93

FORMATS

95       A format string contains any  number  of  format  units,  separated  by
96       whitespace.   A  format  unit  contains up to three items: an iteration
97       count, a byte count, and a format.
98
99       The iteration count is an optional positive integer, which defaults  to
100       one.  Each format is applied iteration count times.
101
102       The  byte  count  is  an  optional  positive  integer.  If specified it
103       defines the number of bytes to be interpreted by each iteration of  the
104       format.
105
106       If  an iteration count and/or a byte count is specified, a single slash
107       must be placed after the iteration count and/or before the  byte  count
108       to  disambiguate  them.   Any  whitespace  before or after the slash is
109       ignored.
110
111       The format is required and must be surrounded by  double  quote  ("  ")
112       marks.   It  is  interpreted  as  a  fprintf-style  format  string (see
113       fprintf(3), with the following exceptions:
114
115       1.     An asterisk (*) may not be used as a field width or precision.
116
117       2.     A byte count or field precision is required for each  s  conver‐
118              sion  character  (unlike the fprintf(3) default which prints the
119              entire string if the precision is unspecified).
120
121       3.     The conversion characters h, l, n, p, and q are not supported.
122
123       4.     The single character escape sequences described in the  C  stan‐
124              dard are supported:
125
126                    NULL                 \0
127                    <alert character>    \a
128                    <backspace>          \b
129                    <form-feed>          \f
130                    <newline>            \n
131                    <carriage return>    \r
132                    <tab>                \t
133                    <vertical tab>       \v
134
135   Conversion strings
136       The  hexdump  utility also supports the following additional conversion
137       strings.
138
139       _a[dox]
140              Display the input offset, cumulative across input files, of  the
141              next  byte to be displayed.  The appended characters d, o, and x
142              specify the  display  base  as  decimal,  octal  or  hexadecimal
143              respectively.
144
145       _A[dox]
146              Identical  to  the  _a  conversion string except that it is only
147              performed once, when all of the input data has been processed.
148
149       _c     Output characters in the default  character  set.   Non-printing
150              characters  are displayed in three-character, zero-padded octal,
151              except for those representable by standard escape notation  (see
152              above), which are displayed as two-character strings.
153
154       _p     Output  characters  in  the default character set.  Non-printing
155              characters are displayed as a single '.'.
156
157       _u     Output US ASCII characters,  with  the  exception  that  control
158              characters are displayed using the following, lower-case, names.
159              Characters greater than  0xff,  hexadecimal,  are  displayed  as
160              hexadecimal strings.
161
162                 000 nul   001 soh   002 stx   003 etx   004 eot   005 enq
163                 006 ack   007 bel   008 bs    009 ht    00A lf    00B vt
164                 00C ff    00D cr    00E so    00F si    010 dle   011 dc1
165                 012 dc2   013 dc3   014 dc4   015 nak   016 syn   017 etb
166                 018 can   019 em    01A sub   01B esc   01C fs    01D gs
167                 01E rs    01F us    0FF del
168
169   Colors
170       When  put  at  the  end  of  a format specifier, hexdump highlights the
171       respective string with the color specified.   Conditions,  if  present,
172       are evaluated prior to highlighting.
173
174       _L[color_unit_1,color_unit_2,...,color_unit_n]
175
176       The full syntax of a color unit is as follows:
177
178       [!]COLOR[:VALUE][@OFFSET_START[-END]]
179
180       !      Negate  the  condition.  Please note that it only makes sense to
181              negate a unit if both a value/string and an  offset  are  speci‐
182              fied.   In  that case the respective output string will be high‐
183              lighted if and only if the value/string does not match  the  one
184              at the offset.
185
186       COLOR  One of the 8 basic shell colors.
187
188       VALUE  A  value  to be matched specified in hexadecimal, or octal base,
189              or as a string.  Please note that the usual C  escape  sequences
190              are not interpreted by hexdump inside the color_units.
191
192       OFFSET An  offset  or  an  offset  range at which to check for a match.
193              Please note that lone OFFSET_START uses the same  value  as  END
194              offset.
195
196   Counters
197       The default and supported byte counts for the conversion characters are
198       as follows:
199
200       %_c, %_p, %_u, %c
201              One byte counts only.
202
203       %d, %i, %o, %u, %X, %x
204              Four byte default, one, two and four byte counts supported.
205
206       %E, %e, %f, %G, %g
207              Eight byte default, four byte counts supported.
208
209       The amount of data interpreted by each format string is the sum of  the
210       data  required  by each format unit, which is the iteration count times
211       the byte count, or the  iteration  count  times  the  number  of  bytes
212       required by the format if the byte count is not specified.
213
214       The  input  is  manipulated  in blocks, where a block is defined as the
215       largest amount of data specified by any format string.  Format  strings
216       interpreting  less than an input block's worth of data, whose last for‐
217       mat unit both interprets some number of bytes and does not have a spec‐
218       ified  iteration  count, have the iteration count incremented until the
219       entire input block has been processed  or  there  is  not  enough  data
220       remaining in the block to satisfy the format string.
221
222       If,  either  as a result of user specification or hexdump modifying the
223       iteration count as described above, an iteration count is greater  than
224       one, no trailing whitespace characters are output during the last iter‐
225       ation.
226
227       It is an error to specify a byte count as well as  multiple  conversion
228       characters  or  strings unless all but one of the conversion characters
229       or strings is _a or _A.
230
231       If, as a result of the specification of the -n  option  or  end-of-file
232       being reached, input data only partially satisfies a format string, the
233       input block is zero-padded sufficiently to display all  available  data
234       (i.e.,  any  format units overlapping the end of data will display some
235       number of the zero bytes).
236
237       Further output by such format strings is replaced by an equivalent num‐
238       ber of spaces.  An equivalent number of spaces is defined as the number
239       of spaces output by an s conversion character with the same field width
240       and precision as the original conversion character or conversion string
241       but with any '+', ´ ´, '#' conversion flag characters removed, and ref‐
242       erencing a NULL string.
243
244       If no format strings are specified, the default display is very similar
245       to the -x output format (the -x option causes more  space  to  be  used
246       between format units than in the default output).
247

EXIT STATUS

249       hexdump exits 0 on success and >0 if an error occurred.
250

EXAMPLES

252       Display the input in perusal format:
253          "%06.6_ao "  12/1 "%3_u "
254          "\t\t" "%_p "
255          "\n"
256
257       Implement the -x option:
258          "%07.7_Ax\n"
259          "%07.7_ax  " 8/2 "%04x " "\n"
260
261       MBR Boot Signature example: Highlight the addresses cyan and the bytes at
262       offsets 510 and 511 green if their value is 0xAA55, red otherwise.
263          "%07.7_Ax_L[cyan]\n"
264          "%07.7_ax_L[cyan]  " 8/2 "   %04x_L[green:0xAA55@510-511,!red:0xAA55@510-511] " "\n"
265

COLORS

267       Implicit  coloring  can be disabled by an empty file /etc/terminal-col‐
268       ors.d/hexdump.disable.
269
270       See terminal-colors.d(5) for more details about colorization configura‐
271       tion.
272

STANDARDS

274       The  hexdump utility is expected to be IEEE Std 1003.2 ("POSIX.2") com‐
275       patible.
276

AVAILABILITY

278       The hexdump command is part of the util-linux package and is  available
279       from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-
280       linux/⟩.
281
282
283
284util-linux                        April 2013                        HEXDUMP(1)
Impressum