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