]> git.saurik.com Git - apple/shell_cmds.git/blob - hexdump/hexdump.1
shell_cmds-170.tar.gz
[apple/shell_cmds.git] / hexdump / hexdump.1
1 .\" Copyright (c) 1989, 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
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 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" @(#)hexdump.1 8.2 (Berkeley) 4/18/94
33 .\" $FreeBSD: src/usr.bin/hexdump/hexdump.1,v 1.21 2004/07/10 13:11:00 tjr Exp $
34 .\"
35 .Dd July 10, 2004
36 .Dt HEXDUMP 1
37 .Os
38 .Sh NAME
39 .Nm hexdump
40 .Nd ASCII, decimal, hexadecimal, octal dump
41 .Sh SYNOPSIS
42 .Nm
43 .Op Fl bcCdovx
44 .Op Fl e Ar format_string
45 .Op Fl f Ar format_file
46 .Op Fl n Ar length
47 .Bk -words
48 .Op Fl s Ar skip
49 .Ek
50 .Ar
51 .Sh DESCRIPTION
52 The
53 .Nm
54 utility is a filter which displays the specified files, or
55 the standard input, if no files are specified, in a user specified
56 format.
57 .Pp
58 The options are as follows:
59 .Bl -tag -width indent
60 .It Fl b
61 .Em One-byte octal display .
62 Display the input offset in hexadecimal, followed by sixteen
63 space-separated, three column, zero-filled, bytes of input data,
64 in octal, per line.
65 .It Fl C
66 .Em Canonical hex+ASCII display .
67 Display the input offset in hexadecimal, followed by sixteen
68 space-separated, two column, hexadecimal bytes, followed by the
69 same sixteen bytes in %_p format enclosed in ``|'' characters.
70 .It Fl c
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
74 data per line.
75 .It Fl d
76 .Em Two-byte decimal display .
77 Display the input offset in hexadecimal, followed by eight
78 space-separated, five column, zero-filled, two-byte units
79 of input data, in unsigned decimal, per line.
80 .It Fl e Ar format_string
81 Specify a format string to be used for displaying data.
82 .It Fl f Ar format_file
83 Specify a file that contains one or more newline separated format strings.
84 Empty lines and lines whose first non-blank character is a hash mark
85 .Pf ( Cm \&# )
86 are ignored.
87 .It Fl n Ar length
88 Interpret only
89 .Ar length
90 bytes of input.
91 .It Fl o
92 .Em Two-byte octal display .
93 Display the input offset in hexadecimal, followed by eight
94 space-separated, six column, zero-filled, two byte quantities of
95 input data, in octal, per line.
96 .It Fl s Ar offset
97 Skip
98 .Ar offset
99 bytes from the beginning of the input.
100 By default,
101 .Ar offset
102 is interpreted as a decimal number.
103 With a leading
104 .Cm 0x
105 or
106 .Cm 0X ,
107 .Ar offset
108 is interpreted as a hexadecimal number,
109 otherwise, with a leading
110 .Cm 0 ,
111 .Ar offset
112 is interpreted as an octal number.
113 Appending the character
114 .Cm b ,
115 .Cm k ,
116 or
117 .Cm m
118 to
119 .Ar offset
120 causes it to be interpreted as a multiple of
121 .Li 512 ,
122 .Li 1024 ,
123 or
124 .Li 1048576 ,
125 respectively.
126 .It Fl v
127 Cause
128 .Nm
129 to display all input data.
130 Without the
131 .Fl v
132 option, any number of groups of output lines, which would be
133 identical to the immediately preceding group of output lines (except
134 for the input offsets), are replaced with a line comprised of a
135 single asterisk.
136 .It Fl x
137 .Em Two-byte hexadecimal display .
138 Display the input offset in hexadecimal, followed by eight, space
139 separated, four column, zero-filled, two-byte quantities of input
140 data, in hexadecimal, per line.
141 .El
142 .Pp
143 For each input file,
144 .Nm
145 sequentially copies the input to standard output, transforming the
146 data according to the format strings specified by the
147 .Fl e
148 and
149 .Fl f
150 options, in the order that they were specified.
151 .Ss Formats
152 A format string contains any number of format units, separated by
153 whitespace.
154 A format unit contains up to three items: an iteration count, a byte
155 count, and a format.
156 .Pp
157 The iteration count is an optional positive integer, which defaults to
158 one.
159 Each format is applied iteration count times.
160 .Pp
161 The byte count is an optional positive integer.
162 If specified it defines the number of bytes to be interpreted by
163 each iteration of the format.
164 .Pp
165 If an iteration count and/or a byte count is specified, a single slash
166 must be placed after the iteration count and/or before the byte count
167 to disambiguate them.
168 Any whitespace before or after the slash is ignored.
169 .Pp
170 The format is required and must be surrounded by double quote
171 (" ") marks.
172 It is interpreted as a fprintf-style format string (see
173 .Xr fprintf 3 ) ,
174 with the
175 following exceptions:
176 .Bl -bullet -offset indent
177 .It
178 An asterisk (*) may not be used as a field width or precision.
179 .It
180 A byte count or field precision
181 .Em is
182 required for each ``s'' conversion
183 character (unlike the
184 .Xr fprintf 3
185 default which prints the entire string if the precision is unspecified).
186 .It
187 The conversion characters ``h'', ``l'', ``n'', ``p'' and ``q'' are
188 not supported.
189 .It
190 The single character escape sequences
191 described in the C standard are supported:
192 .Bd -ragged -offset indent -compact
193 .Bl -column <alert_character>
194 .It "NUL \e0
195 .It "<alert character> \ea
196 .It "<backspace> \eb
197 .It "<form-feed> \ef
198 .It "<newline> \en
199 .It "<carriage return> \er
200 .It "<tab> \et
201 .It "<vertical tab> \ev
202 .El
203 .Ed
204 .El
205 .Pp
206 The
207 .Nm
208 utility also supports the following additional conversion strings:
209 .Bl -tag -width Fl
210 .It Cm \&_a Ns Op Cm dox
211 Display the input offset, cumulative across input files, of the
212 next byte to be displayed.
213 The appended characters
214 .Cm d ,
215 .Cm o ,
216 and
217 .Cm x
218 specify the display base
219 as decimal, octal or hexadecimal respectively.
220 .It Cm \&_A Ns Op Cm dox
221 Identical to the
222 .Cm \&_a
223 conversion string except that it is only performed
224 once, when all of the input data has been processed.
225 .It Cm \&_c
226 Output characters in the default character set.
227 Nonprinting characters are displayed in three character, zero-padded
228 octal, except for those representable by standard escape notation
229 (see above),
230 which are displayed as two character strings.
231 .It Cm _p
232 Output characters in the ASCII character set.
233 Non-ASCII characters are displayed as a single
234 .Dq Cm \&. .
235 .It Cm _u
236 Output US
237 .Tn ASCII
238 characters, with the exception that control characters are
239 displayed using the following, lower-case, names.
240 Characters greater than 0xff, hexadecimal, are displayed as hexadecimal
241 strings.
242 .Bl -column \&000_nu \&001_so \&002_st \&003_et \&004_eo
243 .It "\&000\ NUL\t001\ SOH\t002\ STX\t003\ ETX\t004\ EOT\t005\ ENQ
244 .It "\&006\ ACK\t007\ BEL\t008\ BS\t009\ HT\t00A\ LF\t00B\ VT
245 .It "\&00C\ FF\t00D\ CR\t00E\ SO\t00F\ SI\t010\ DLE\t011\ DC1
246 .It "\&012\ DC2\t013\ DC3\t014\ DC4\t015\ NAK\t016\ SYN\t017\ ETB
247 .It "\&018\ CAN\t019\ EM\t01A\ SUB\t01B\ ESC\t01C\ FS\t01D\ GS
248 .It "\&01E\ RS\t01F\ US\t0FF\ DEL
249 .El
250 .El
251 .Pp
252 The default and supported byte counts for the conversion characters
253 are as follows:
254 .Bl -tag -width "Xc,_Xc,_Xc,_Xc,_Xc,_Xc" -offset indent
255 .It Li \&%_c , \&%_p , \&%_u , \&%c
256 One byte counts only.
257 .It Xo
258 .Li \&%d , \&%i , \&%o ,
259 .Li \&%u , \&%X , \&%x
260 .Xc
261 Four byte default, one, two and four byte counts supported.
262 .It Xo
263 .Li \&%E , \&%e , \&%f ,
264 .Li \&%G , \&%g
265 .Xc
266 Eight byte default, four and twelve byte counts supported.
267 .El
268 .Pp
269 The amount of data interpreted by each format string is the sum of the
270 data required by each format unit, which is the iteration count times the
271 byte count, or the iteration count times the number of bytes required by
272 the format if the byte count is not specified.
273 .Pp
274 The input is manipulated in ``blocks'', where a block is defined as the
275 largest amount of data specified by any format string.
276 Format strings interpreting less than an input block's worth of data,
277 whose last format unit both interprets some number of bytes and does
278 not have a specified iteration count, have the iteration count
279 incremented until the entire input block has been processed or there
280 is not enough data remaining in the block to satisfy the format string.
281 .Pp
282 If, either as a result of user specification or
283 .Nm
284 modifying
285 the iteration count as described above, an iteration count is
286 greater than one, no trailing whitespace characters are output
287 during the last iteration.
288 .Pp
289 It is an error to specify a byte count as well as multiple conversion
290 characters or strings unless all but one of the conversion characters
291 or strings is
292 .Cm \&_a
293 or
294 .Cm \&_A .
295 .Pp
296 If, as a result of the specification of the
297 .Fl n
298 option or end-of-file being reached, input data only partially
299 satisfies a format string, the input block is zero-padded sufficiently
300 to display all available data (i.e., any format units overlapping the
301 end of data will display some number of the zero bytes).
302 .Pp
303 Further output by such format strings is replaced by an equivalent
304 number of spaces.
305 An equivalent number of spaces is defined as the number of spaces
306 output by an
307 .Cm s
308 conversion character with the same field width
309 and precision as the original conversion character or conversion
310 string but with any
311 .Dq Li \&+ ,
312 .Dq \&\ \& ,
313 .Dq Li \&#
314 conversion flag characters
315 removed, and referencing a NULL string.
316 .Pp
317 If no format strings are specified, the default display is a
318 one-byte hexadecimal display.
319 .Sh DIAGNOSTICS
320 .Ex -std
321 .Sh EXAMPLES
322 Note that the following format strings, used with
323 .Fl e ,
324 must be enclosed in single quotes.
325 .Pp
326 Display the input in perusal format:
327 .Bd -literal -offset indent
328 "%06.6_ao " 12/1 "%3_u "
329 "\et\et" "%_p "
330 "\en"
331 .Ed
332 .Pp
333 Implement the \-x option:
334 .Bd -literal -offset indent
335 "%07.7_Ax\en"
336 "%07.7_ax " 8/2 "%04x " "\en"
337 .Ed
338 .Sh SEE ALSO
339 .Xr gdb 1 ,
340 .Xr od 1