Commit | Line | Data |
---|---|---|
90e4be46 KB |
1 | .\" Copyright (c) 1989 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms are permitted | |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | .\" | |
6d23aef6 | 16 | .\" @(#)hexdump.1 5.2 (Berkeley) %G% |
90e4be46 KB |
17 | .\" |
18 | .TH HEXDUMP 1 "" | |
19 | .UC 7 | |
20 | .SH NAME | |
21 | hexdump - ascii, decimal, hexadecimal, octal dump | |
22 | .SH SYNOPSIS | |
23 | hexdump | |
24 | .ft B | |
25 | [ | |
26 | .I -bcdov | |
27 | .ft B | |
28 | ] [ | |
29 | .I -e format_string | |
30 | .ft B | |
31 | ] [ | |
32 | .I -f format_file | |
33 | .ft B | |
34 | ] [ | |
35 | .I -n length | |
36 | .ft B | |
37 | ] [ | |
38 | .I -s skip | |
39 | .ft B | |
40 | ] [ | |
41 | .I file ... | |
42 | .ft B | |
43 | ] | |
44 | .ft R | |
45 | .SH DESCRIPTION | |
46 | The hexdump utility is a filter that displays the specified files, or | |
47 | the standard input, if no files are specified, in a user specified | |
48 | format. | |
49 | .PP | |
50 | The options are as follows: | |
51 | .TP | |
52 | -b | |
53 | Display the input offset in hexadecimal, followed by sixteen | |
54 | space-separated, three column, zero-filled, bytes of input data, | |
55 | in octal, per line. | |
56 | It is equivalent to specifying the following format strings: | |
57 | .ti +5 | |
58 | "%07.7_Ax\en" | |
59 | .ti +5 | |
60 | "%07.7_ax " 16/1 "%03o " "\en" | |
61 | .TP | |
62 | -c | |
63 | Display the input offset in hexadecimal, followed by sixteen | |
64 | space-separated, three column, space-filled, characters of input | |
65 | data per line. | |
66 | It is equivalent to specifying the following format strings: | |
67 | .ti +5 | |
68 | "%07.7_Ax\en" | |
69 | .ti +5 | |
70 | "%07.7_ax " 16/1 "%3_c " "\en" | |
71 | .TP | |
72 | -d | |
73 | Display the input offset in hexadecimal, followed by eight | |
74 | space-separated, five column, zero-filled, two-byte units | |
75 | of input data, in unsigned decimal, per line. | |
76 | It is equivalent to specifying the following format strings: | |
77 | .ti +5 | |
78 | "%07.7_Ax\en" | |
79 | .ti +5 | |
80 | "%07.7_ax " 8/2 "%05u " "\en" | |
81 | .TP | |
82 | -e | |
83 | Specify a format string to be used for displaying data. | |
84 | .TP | |
85 | -f | |
86 | Specify a file that contains one or more newline separated format strings. | |
87 | Empty lines and lines whose first non-blank character is a hash mark | |
88 | (#) are ignored. | |
89 | .TP | |
90 | -n | |
91 | Interpret only | |
92 | .I length | |
93 | bytes of input. | |
94 | .TP | |
95 | -o | |
96 | Display the input offset in hexadecimal, followed by eight | |
97 | space-separated, six column, zero-filled, two byte quantities of | |
98 | input data, in octal, per line. | |
99 | It is equivalent to specifying the following format strings: | |
100 | .ti +5 | |
101 | "%07.7_Ax\en" | |
102 | .ti +5 | |
103 | "%07.7_ax " 8/2 "%06o " "\en" | |
104 | .TP | |
105 | -s | |
106 | Skip | |
107 | .I offset | |
108 | bytes from the beginning of the input. | |
109 | By default, | |
110 | .I offset | |
111 | is interpreted as a decimal number. | |
112 | With a leading ``0x'' or ``0X'', | |
113 | .I offset | |
114 | is interpreted as a hexadecimal number, | |
115 | otherwise, with a leading ``0'', | |
116 | .I offset | |
117 | is interpreted as an octal number. | |
118 | Appending the character ``b'', ``k'', or ``m'' to | |
119 | .I offset | |
120 | causes it to be interpreted as a multiple of 512, 1024, or 1048576, | |
121 | respectively. | |
122 | .TP | |
123 | -v | |
124 | The | |
125 | .I -v | |
126 | option causes hexdump to display all input data. | |
127 | Without the | |
128 | .I -v | |
129 | option, any number of groups of output lines, which would be | |
130 | identical to the immediately preceding group of output lines (except | |
131 | for the input offsets), are replaced with a line comprised of a | |
132 | single asterisk. | |
133 | .PP | |
134 | For each input file, | |
135 | .I hexdump | |
136 | sequentially copies the input to standard output, transforming the | |
137 | data according to the format strings specified by the | |
138 | .I -e | |
139 | and | |
140 | .I -f | |
141 | options, in the order that they were specified. | |
142 | .PP | |
143 | A format string contains any number of format units, separated by | |
144 | whitespace. | |
145 | A format unit contains up to three items: an iteration count, a byte | |
146 | count, and a format. | |
147 | .PP | |
148 | The iteration count is an optional positive integer, which defaults to | |
149 | one. | |
150 | Each format is applied iteration count times. | |
151 | .PP | |
152 | The byte count is an optional positive integer. | |
153 | If specified it defines the number of bytes to be interpreted by | |
154 | each iteration of the format. | |
155 | .PP | |
156 | If an iteration count and/or a byte count is specified, a single slash | |
157 | must be placed after the iteration count and/or before the byte count | |
158 | to disambiguate them. | |
159 | Any whitespace before or after the slash is ignored. | |
160 | .PP | |
161 | The format is required and must be surrounded by double quote | |
162 | (" ") marks. | |
163 | It is interpreted as a fprintf-style format string, with the | |
164 | following exceptions: | |
165 | .TP | |
166 | .B \(bu | |
167 | An asterisk (*) may not be used as a field width or precision. | |
168 | .TP | |
169 | .B \(bu | |
170 | A byte count or field precision is required for each ``s'' conversion | |
171 | character. | |
172 | .TP | |
173 | .B \(bu | |
174 | The conversion characters ``h'', ``l'', ``n'', and ``p'' are not | |
175 | supported. | |
176 | .TP | |
177 | .B \(bu | |
178 | The single character escape sequences (\ea, \eb, \ef, \en, \er, | |
179 | \et, and \ev) described in the C standard are supported. | |
180 | .PP | |
181 | Hexdump also supports the the following additional conversion strings: | |
182 | .PP | |
183 | .TP | |
184 | _a[dox] | |
185 | Display the input offset, cumulative across input files, of the | |
186 | next byte to be displayed. | |
187 | The appended characters ``d'', ``o'', and ``x'' specify the display base | |
188 | as decimal, octal or hexadecimal respectively. | |
189 | .TP | |
190 | _A[dox] | |
191 | Identical to the _a conversion string except that it is only performed | |
192 | once, when all of the input data has been processed. | |
193 | .TP | |
194 | _c | |
195 | Output characters in the default character set. | |
196 | Nonprinting characters are displayed in hexadecimal, except for those | |
197 | representable by standard escape notation, which are displayed | |
198 | as follows: | |
199 | .in +5 | |
200 | .TS | |
201 | l l. | |
202 | NUL \e0 | |
203 | <alert character> \ea | |
204 | <backspace> \eb | |
205 | <form-feed> \ef | |
206 | <newline> \en | |
207 | <carriage return> \er | |
208 | <tab> \et | |
209 | <vertical tab> \ev | |
210 | .TE | |
211 | .TP | |
212 | _p | |
213 | Output characters in the default character set. | |
214 | Nonprinting characters are displayed as a single ``.''. | |
215 | .TP | |
216 | _u | |
217 | Output US ASCII characters, with the exception that control characters are | |
218 | displayed using the following, lower-case, names. | |
219 | Characters greater than 0xff, hexadecimal, are displayed as hexadecimal | |
220 | strings. | |
221 | .in +5 | |
222 | .TS | |
223 | l l l l l l. | |
224 | 00 nul 001 soh 002 stx 003 etx 004 eot 005 enq | |
225 | 06 ack 007 bel 008 bs 009 ht 00A lf 00B vt | |
226 | 0C ff 00D cr 00E so 00F si 010 dle 011 dc1 | |
227 | 12 dc2 013 dc3 014 dc4 015 nak 016 syn 017 etb | |
228 | 18 can 019 em 01A sub 01B esc 01C fs 01D gs | |
229 | 01E rs 01F us 0FF del | |
230 | .TE | |
231 | .PP | |
232 | The default and supported byte counts are as follows: | |
233 | .in +5 | |
234 | .TS | |
235 | l l l. | |
236 | Conversion type Default (bytes) Other Supported (bytes) | |
237 | _ | |
238 | %_c 1 | |
239 | %_p 1 | |
240 | %_u 1 | |
241 | %c 1 | |
242 | %d (%i) 4 1, 2 | |
243 | %o 4 1, 2 | |
244 | %u 4 1, 2 | |
245 | %x (%X) 4 1, 2 | |
246 | %e (%E) 8 4 | |
247 | %f 8 4 | |
248 | %g (%G) 8 4 | |
249 | .TE | |
250 | .PP | |
251 | The amount of data interpreted by each format string is the sum of the | |
252 | data required by each format unit, which is the iteration count times the | |
253 | byte count, or the iteration count times the number of bytes required by | |
254 | the format if the byte count is not specified. | |
255 | .PP | |
256 | The input is manipulated in ``blocks'', where a block is defined as the | |
257 | largest amount of data specified by any format string. | |
258 | Format strings interpreting less than an input block's worth of data, | |
259 | whose last format unit both interprets some number of bytes and does | |
260 | not have a specified iteration count, have the the interation count | |
261 | incremented until the entire input block has been processed or there | |
262 | is not enough data remaining in the block to satisfy the format string. | |
263 | .PP | |
264 | If, either as a result of user specification or hexdump modifying | |
265 | the iteration count as described above, an iteration count is | |
266 | greater than one, no trailing whitespace characters are output | |
267 | during the last iteration. | |
268 | .PP | |
269 | It is an error to specify a byte count as well as multiple conversion | |
270 | characters or strings unless all but one of the conversion characters | |
271 | or strings is ``_a'' or ``_A''. | |
272 | .PP | |
273 | If, as a result of the specification of the | |
274 | .I -n | |
275 | option or end-of-file being reached, input data only partially | |
276 | satisfies a format string, the input block is zero-padded sufficiently | |
277 | to display all available data (i.e. any format units overlapping the | |
278 | end of data will display some number of the zero bytes). | |
279 | .PP | |
280 | Further output by such format strings is replaced by an equivalent | |
281 | number of spaces. | |
282 | An equivalent number of spaces is defined as the number of spaces | |
283 | output by an ``s'' conversion character with the same field width | |
284 | and precision as the original conversion character or conversion | |
285 | string but with any ``+'', `` '', or ``#'' conversion flag characters | |
286 | removed, and referencing a NULL string. | |
90e4be46 KB |
287 | .PP |
288 | If no format strings are specified, the default display is equivalent | |
289 | to specifying the following format strings: | |
290 | .ti +5 | |
291 | "%07.7_Ax\en" | |
292 | .ti +5 | |
293 | "%07.7_ax " 8/2 "%04x " "\en" | |
294 | .sp | |
295 | This displays the input offset in hexadecimal, followed by eight, space | |
296 | separated, four column, zero-filled, two-byte quantities of input | |
297 | data, in hexadecimal, per line. | |
298 | .PP | |
299 | .I Hexdump | |
300 | exits 0 on success and >0 if an error occurred. | |
301 | .SH EXAMPLES | |
302 | Display the input in perusal format: | |
303 | .sp | |
304 | .ti +5 | |
305 | "%06.6_ao " 12/1 "%3o " | |
306 | .ti +5 | |
307 | "\et\et" "%_p " | |
308 | .ti +5 | |
309 | "\en" |