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.\" 34.Dd April 18, 1994 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 51The hexdump utility is a filter which displays the specified files, or 52the standard input, if no files are specified, in a user specified 53format. 54.Pp 55The options are as follows: 56.Bl -tag -width Fl 57.It Fl b 58.Em One-byte octal display . 59Display the input offset in hexadecimal, followed by sixteen 60space-separated, three column, zero-filled, bytes of input data, 61in octal, per line. 62.It Fl c 63.Em One-byte character display . 64Display the input offset in hexadecimal, followed by sixteen 65space-separated, three column, space-filled, characters of input 66data per line. 67.It Fl d 68.Em Two-byte decimal display. 69Display the input offset in hexadecimal, followed by eight 70space-separated, five column, zero-filled, two-byte units 71of input data, in unsigned decimal, per line. 72.It Fl e Ar format_string 73Specify a format string to be used for displaying data. 74.It Fl f Ar format_file 75Specify a file that contains one or more newline separated format strings. 76Empty lines and lines whose first non-blank character is a hash mark 77.Pf ( Cm \&# ) 78are ignored. 79.It Fl n Ar length 80Interpret only 81.Ar length 82bytes of input. 83.It Fl o 84.Em Two-byte octal display. 85Display the input offset in hexadecimal, followed by eight 86space-separated, six column, zero-filled, two byte quantities of 87input data, in octal, per line. 88.It Fl s Ar offset 89Skip 90.Ar offset 91bytes from the beginning of the input. 92By default, 93.Ar offset 94is interpreted as a decimal number. 95With a leading 96.Cm 0x 97or 98.Cm 0X , 99.Ar offset 100is interpreted as a hexadecimal number, 101otherwise, with a leading 102.Cm 0 , 103.Ar offset 104is interpreted as an octal number. 105Appending the character 106.Cm b , 107.Cm k , 108or 109.Cm m 110to 111.Ar offset 112causes it to be interpreted as a multiple of 113.Li 512 , 114.Li 1024 , 115or 116.Li 1048576 , 117respectively. 118.It Fl v 119The 120.Fl v 121option causes hexdump to display all input data. 122Without the 123.Fl v 124option, any number of groups of output lines, which would be 125identical to the immediately preceding group of output lines (except 126for the input offsets), are replaced with a line comprised of a 127single asterisk. 128.It Fl x 129.Em Two-byte hexadecimal display. 130Display the input offset in hexadecimal, followed by eight, space 131separated, four column, zero-filled, two-byte quantities of input 132data, in hexadecimal, per line. 133.El 134.Pp 135For each input file, 136.Nm hexdump 137sequentially copies the input to standard output, transforming the 138data according to the format strings specified by the 139.Fl e 140and 141.Fl f 142options, in the order that they were specified. 143.Ss Formats 144A format string contains any number of format units, separated by 145whitespace. 146A format unit contains up to three items: an iteration count, a byte 147count, and a format. 148.Pp 149The iteration count is an optional positive integer, which defaults to 150one. 151Each format is applied iteration count times. 152.Pp 153The byte count is an optional positive integer. 154If specified it defines the number of bytes to be interpreted by 155each iteration of the format. 156.Pp 157If an iteration count and/or a byte count is specified, a single slash 158must be placed after the iteration count and/or before the byte count 159to disambiguate them. 160Any whitespace before or after the slash is ignored. 161.Pp 162The format is required and must be surrounded by double quote 163(" ") marks. 164It is interpreted as a fprintf-style format string (see 165.Xr fprintf 3 ) , 166with the 167following exceptions: 168.Bl -bullet -offset indent 169.It 170An asterisk (*) may not be used as a field width or precision. 171.It 172A byte count or field precision 173.Em is 174required for each ``s'' conversion 175character (unlike the 176.Xr fprintf 3 177default which prints the entire string if the precision is unspecified). 178.It 179The conversion characters ``h'', ``l'', ``n'', ``p'' and ``q'' are 180not supported. 181.It 182The single character escape sequences 183described 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 198Hexdump also supports the the following additional conversion strings: 199.Bl -tag -width Fl 200.It Cm \&_a Ns Op Cm dox 201Display the input offset, cumulative across input files, of the 202next byte to be displayed. 203The appended characters 204.Cm d , 205.Cm o , 206and 207.Cm x 208specify the display base 209as decimal, octal or hexadecimal respectively. 210.It Cm \&_A Ns Op Cm dox 211Identical to the 212.Cm \&_a 213conversion string except that it is only performed 214once, when all of the input data has been processed. 215.It Cm \&_c 216Output characters in the default character set. 217Nonprinting characters are displayed in three character, zero-padded 218octal, except for those representable by standard escape notation 219(see above), 220which are displayed as two character strings. 221.It Cm _p 222Output characters in the default character set. 223Nonprinting characters are displayed as a single 224.Dq Cm \&. . 225.It Cm _u 226Output US ASCII characters, with the exception that control characters are 227displayed using the following, lower-case, names. 228Characters greater than 0xff, hexadecimal, are displayed as hexadecimal 229strings. 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 240The default and supported byte counts for the conversion characters 241are as follows: 242.Bl -tag -width "Xc,_Xc,_Xc,_Xc,_Xc,_Xc" -offset indent 243.It Li \&%_c , \&%_p , \&%_u , \&%c 244One byte counts only. 245.It Xo 246.Li \&%d , \&%i , \&%o , 247.Li \&%u , \&%X , \&%x 248.Xc 249Four byte default, one, two and four byte counts supported. 250.It Xo 251.Li \&%E , \&%e , \&%f , 252.Li \&%G , \&%g 253.Xc 254Eight byte default, four byte counts supported. 255.El 256.Pp 257The amount of data interpreted by each format string is the sum of the 258data required by each format unit, which is the iteration count times the 259byte count, or the iteration count times the number of bytes required by 260the format if the byte count is not specified. 261.Pp 262The input is manipulated in ``blocks'', where a block is defined as the 263largest amount of data specified by any format string. 264Format strings interpreting less than an input block's worth of data, 265whose last format unit both interprets some number of bytes and does 266not have a specified iteration count, have the iteration count 267incremented until the entire input block has been processed or there 268is not enough data remaining in the block to satisfy the format string. 269.Pp 270If, either as a result of user specification or hexdump modifying 271the iteration count as described above, an iteration count is 272greater than one, no trailing whitespace characters are output 273during the last iteration. 274.Pp 275It is an error to specify a byte count as well as multiple conversion 276characters or strings unless all but one of the conversion characters 277or strings is 278.Cm \&_a 279or 280.Cm \&_A . 281.Pp 282If, as a result of the specification of the 283.Fl n 284option or end-of-file being reached, input data only partially 285satisfies a format string, the input block is zero-padded sufficiently 286to display all available data (i.e. any format units overlapping the 287end of data will display some number of the zero bytes). 288.Pp 289Further output by such format strings is replaced by an equivalent 290number of spaces. 291An equivalent number of spaces is defined as the number of spaces 292output by an 293.Cm s 294conversion character with the same field width 295and precision as the original conversion character or conversion 296string but with any 297.Dq Li \&+ , 298.Dq \&\ \& , 299.Dq Li \&# 300conversion flag characters 301removed, and referencing a NULL string. 302.Pp 303If no format strings are specified, the default display is equivalent 304to specifying the 305.Fl x 306option. 307.Pp 308.Nm hexdump 309exits 0 on success and >0 if an error occurred. 310.Sh EXAMPLES 311Display 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 318Implement 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