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