1 .TH XXD 1 "August 1996" "Manual page for xxd"
5 .\" Tony Nugent <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au>
6 .\" Changes by Bram Moolenaar <Bram@vim.org>
9 \- make a hexdump or do the reverse.
15 [options] [infile [outfile]]
18 \-r[evert] [options] [infile [outfile]]
21 creates a hex dump of a given file or standard input.
22 It can also convert a hex dump back to its original binary form.
27 it allows the transmission of binary data in a `mail-safe' ASCII representation,
28 but has the advantage of decoding to standard output.
29 Moreover, it can be used to perform binary file patching.
33 is given, standard input is read.
38 character, then input is taken from standard input.
43 character is in its place), results are sent to standard output.
45 Note that a "lazy" parser is used which does not check for more than the first
46 option letter, unless the option is followed by a parameter.
47 Spaces between a single option letter and its parameter are optional.
48 Parameters to options can be specified in decimal, hexadecimal or octal
59 .IR \-a " | " \-autoskip
60 toggle autoskip: A single '*' replaces nul-lines. Default off.
63 Switch to bits (binary digits) dump, rather than hexdump.
64 This option writes octets as eight digits "1"s and "0"s instead of a normal
65 hexadecimal dump. Each line is preceded by a line number in hexadecimal and
66 followed by an ascii (or ebcdic) representation. The command line switches
67 \-r, \-p, \-i do not work with this mode.
69 .IR "\-c cols " | " \-cols cols"
72 octets per line. Default 16 (\-i: 12, \-ps: 30, \-b: 6). Max 256.
74 .IR \-E " | " \-EBCDIC
75 Change the character encoding in the righthand column from ASCII to EBCDIC.
76 This does not change the hexadecimal representation. The option is
77 meaningless in combinations with \-r, \-p or \-i.
79 .IR "\-g bytes " | " \-groupsize bytes"
80 separate the output of every
82 bytes (two hex characters or eight bit-digits each) by a whitespace.
86 .RI < Bytes "> defaults to " 2
87 in normal mode and \fI1\fP in bits mode.
88 Grouping does not apply to postscript or include style.
91 print a summary of available commands and exit. No hex dumping is performed.
93 .IR \-i " | " \-include
94 output in C include file style. A complete static array definition is written
95 (named after the input file), unless xxd reads from stdin.
97 .IR "\-l len " | " \-len len"
102 .IR \-p " | " \-ps " | " \-postscript " | " \-plain
103 output in postscript continuous hexdump style. Also known as plain hexdump
106 .IR \-r " | " \-revert
107 reverse operation: convert (or patch) hexdump into binary.
108 If not writing to stdout, xxd writes into its output file without truncating
109 it. Use the combination
111 to read plain hexadecimal dumps without line number information and without a
112 particular column layout. Additional Whitespace and line-breaks are allowed
120 added to file positions found in hexdump.
125 bytes abs. (or rel.) infile offset.
126 \fI+ \fRindicates that the seek is relative to the current stdin file position
127 (meaningless when not reading from stdin). \fI\- \fRindicates that the seek
128 should be that many characters from the end of the input (or if combined with
129 \fI+\fR: before the current stdin file position).
130 Without \-s option, xxd starts at the current file position.
133 use upper case hex letters. Default is lower case.
135 .IR \-v " | " \-version
140 has some builtin magic while evaluating line number information.
141 If the output file is seekable, then the linenumbers at the start of each
142 hexdump line may be out of order, lines may be missing, or overlapping. In
143 these cases xxd will lseek(2) to the next position. If the output file is not
144 seekable, only gaps are allowed, which will be filled by null-bytes.
147 never generates parse errors. Garbage is silently skipped.
149 When editing hexdumps, please note that
151 skips everything on the input line after reading enough columns of hexadecimal
152 data (see option \-c). This also means, that changes to the printable ascii (or
153 ebcdic) columns are always ignored. Reverting a plain (or postscript) style
154 hexdump with xxd \-r \-p does not depend on the correct number of columns. Here anything that looks like a pair of hex-digits is interpreted.
156 Note the difference between
162 \fI% xxd \-i < file\fR
165 may be different from
167 as lseek(2) is used to "rewind" input. A '+'
168 makes a difference if the input source is stdin, and if stdin's file position
169 is not at the start of the file by the time xxd is started and given its input.
170 The following examples may help to clarify (or further confuse!)...
172 Rewind stdin before reading; needed because the `cat' has already read to the
175 \fI% sh \-c "cat > plain_copy; xxd \-s 0 > hex_copy" < file\fR
177 Hexdump from file position 0x480 (=1024+128) onwards.
178 The `+' sign means "relative to the current position", thus the `128' adds to
179 the 1k where dd left off.
181 \fI% sh \-c "dd of=plain_snippet bs=1k count=1; xxd \-s +128 > hex_snippet" < file\fR
183 Hexdump from file position 0x100 ( = 1024\-768) on.
185 \fI% sh \-c "dd of=plain_snippet bs=1k count=1; xxd \-s +\-768 > hex_snippet" < file\fR
187 However, this is a rare situation and the use of `+' is rarely needed.
188 The author prefers to monitor the effect of xxd with strace(1) or truss(1), whenever \-s is used.
192 Print everything but the first three lines (hex 0x30 bytes) of
195 \fI% xxd \-s 0x30 file\fR
198 Print 3 lines (hex 0x30 bytes) from the end of
201 \fI% xxd \-s \-0x30 file\fR
204 Print 120 bytes as continuous hexdump with 20 octets per line.
206 \fI% xxd \-l 120 \-ps \-c 20 xxd.1\fR
208 2e54482058584420312022417567757374203139
210 39362220224d616e75616c207061676520666f72
212 20787864220a2e5c220a2e5c222032317374204d
214 617920313939360a2e5c22204d616e2070616765
216 20617574686f723a0a2e5c2220202020546f6e79
218 204e7567656e74203c746f6e79407363746e7567
222 Hexdump the first 120 bytes of this man page with 12 octets per line.
224 \fI% xxd \-l 120 \-c 12 xxd.1\fR
226 0000000: 2e54 4820 5858 4420 3120 2241 .TH XXD 1 "A
228 000000c: 7567 7573 7420 3139 3936 2220 ugust 1996"
230 0000018: 224d 616e 7561 6c20 7061 6765 "Manual page
232 0000024: 2066 6f72 2078 7864 220a 2e5c for xxd"..\\
234 0000030: 220a 2e5c 2220 3231 7374 204d "..\\" 21st M
236 000003c: 6179 2031 3939 360a 2e5c 2220 ay 1996..\\"
238 0000048: 4d61 6e20 7061 6765 2061 7574 Man page aut
240 0000054: 686f 723a 0a2e 5c22 2020 2020 hor:..\\"
242 0000060: 546f 6e79 204e 7567 656e 7420 Tony Nugent
244 000006c: 3c74 6f6e 7940 7363 746e 7567 <tony@sctnug
247 Display just the date from the file xxd.1
249 \fI% xxd \-s 0x36 \-l 13 \-c 13 xxd.1\fR
251 0000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996
258 and prepend 100 bytes of value 0x00.
260 \fI% xxd input_file | xxd \-r \-s 100 > output_file\fR
264 Patch the date in the file xxd.1
266 \fI% echo "0000037: 3574 68" | xxd \-r \- xxd.1\fR
268 \fI% xxd \-s 0x36 \-l 13 \-c 13 xxd.1\fR
270 0000036: 3235 7468 204d 6179 2031 3939 36 25th May 1996
273 Create a 65537 byte file with all bytes 0x00,
274 except for the last one which is 'A' (hex 0x41).
276 \fI% echo "010000: 41" | xxd \-r > file\fR
279 Hexdump this file with autoskip.
281 \fI% xxd \-a \-c 12 file\fR
283 0000000: 0000 0000 0000 0000 0000 0000 ............
287 000fffc: 0000 0000 40 ....A
289 Create a 1 byte file containing a single 'A' character.
290 The number after '\-r \-s' adds to the linenumbers found in the file;
291 in effect, the leading bytes are suppressed.
293 \fI% echo "010000: 41" | xxd \-r \-s \-0x10000 > file\fR
295 Use xxd as a filter within an editor such as
297 to hexdump a region marked between `a' and `z'.
301 Use xxd as a filter within an editor such as
303 to recover a binary hexdump marked between `a' and `z'.
307 Use xxd as a filter within an editor such as
309 to recover one line of a hexdump. Move the cursor over the line and type:
313 Read single characters from a serial line
315 \fI% xxd \-c1 < /dev/term/b &\fR
317 \fI% stty < /dev/term/b \-echo \-opost \-isig \-icanon min 1\fR
319 \fI% echo \-n foo > /dev/term/b\fR
322 The following error values are returned:
325 no errors encountered.
328 operation not supported (
333 error while parsing options.
336 problems with input file.
339 problems with output file.
342 desired seek position is unreachable.
344 uuencode(1), uudecode(1), patch(1)
347 The tools weirdness matches its creators brain.
348 Use entirely at your own risk. Copy files. Trace it. Become a wizard.
351 This manual page documents xxd version 1.7
354 (c) 1990-1997 by Juergen Weigert
356 <jnweiger@informatik.uni\-erlangen.de>
358 Distribute freely and credit me,
360 make money and share with me,
362 lose money and don't ask me.
364 Manual page started by Tony Nugent
366 <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au>
368 Small changes by Bram Moolenaar.
369 Edited by Juergen Weigert.