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