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