7
|
1 .TH XXD 1 "August 1996" "Manual page for xxd"
|
|
2 .\"
|
|
3 .\" 21st May 1996
|
|
4 .\" Man page author:
|
|
5 .\" Tony Nugent <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au>
|
|
6 .\" Changes by Bram Moolenaar <Bram@vim.org>
|
|
7 .SH NAME
|
|
8 .I xxd
|
|
9 \- make a hexdump or do the reverse.
|
|
10 .SH SYNOPSIS
|
|
11 .B xxd
|
|
12 \-h[elp]
|
|
13 .br
|
|
14 .B xxd
|
|
15 [options] [infile [outfile]]
|
|
16 .br
|
|
17 .B xxd
|
|
18 \-r[evert] [options] [infile [outfile]]
|
|
19 .SH DESCRIPTION
|
|
20 .I xxd
|
|
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.
|
|
23 Like
|
|
24 .BR uuencode(1)
|
|
25 and
|
|
26 .BR uudecode(1)
|
|
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.
|
|
30 .SH OPTIONS
|
|
31 If no
|
|
32 .I infile
|
|
33 is given, standard input is read.
|
|
34 If
|
|
35 .I infile
|
|
36 is specified as a
|
|
37 .RB \` \- '
|
|
38 character, then input is taken from standard input.
|
|
39 If no
|
|
40 .I outfile
|
|
41 is given (or a
|
|
42 .RB \` \- '
|
|
43 character is in its place), results are sent to standard output.
|
|
44 .PP
|
|
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
|
|
49 notation.
|
|
50 Thus
|
|
51 .BR \-c8 ,
|
|
52 .BR "\-c 8" ,
|
|
53 .B \-c 010
|
|
54 and
|
|
55 .B \-cols 8
|
|
56 are all equivalent.
|
|
57 .PP
|
|
58 .TP
|
|
59 .IR \-a " | " \-autoskip
|
|
60 toggle autoskip: A single '*' replaces nul-lines. Default off.
|
|
61 .TP
|
|
62 .IR \-b " | " \-bits
|
|
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 hexacecimal 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.
|
|
68 .TP
|
|
69 .IR "\-c cols " | " \-cols cols"
|
|
70 .IR "\-c cols " | " \-cols cols"
|
|
71 format
|
|
72 .RI < cols >
|
|
73 octets per line. Default 16 (\-i: 12, \-ps: 30, \-b: 6). Max 256.
|
|
74 .TP
|
|
75 .IR \-E " | " \-EBCDIC
|
|
76 Change the character encoding in the righthand column from ASCII to EBCDIC.
|
|
77 This does not change the hexadecimal representation. The option is
|
|
78 meaningless in combinations with \-r, \-p or \-i.
|
|
79 .TP
|
|
80 .IR "\-g bytes " | " \-groupsize bytes"
|
|
81 seperate the output of every
|
|
82 .RI < bytes >
|
|
83 bytes (two hex characters or eight bit-digits each) by a whitespace.
|
|
84 Specify
|
|
85 .I \-g 0
|
|
86 to suppress grouping.
|
|
87 .RI < Bytes "> defaults to " 2
|
|
88 in normal mode and \fI1\fP in bits mode.
|
|
89 Grouping does not apply to postscript or include style.
|
|
90 .TP
|
|
91 .IR \-h " | " \-help
|
|
92 print a summary of available commands and exit. No hex dumping is performed.
|
|
93 .TP
|
|
94 .IR \-i " | " \-include
|
|
95 output in C include file style. A complete static array definition is written
|
|
96 (named after the input file), unless xxd reads from stdin.
|
|
97 .TP
|
|
98 .IR "\-l len " | " \-len len"
|
|
99 stop after writing
|
|
100 .RI < len >
|
|
101 octets.
|
|
102 .TP
|
|
103 .IR \-p " | " \-ps " | " \-postscript " | " \-plain
|
|
104 output in postscript continuous hexdump style. Also known as plain hexdump
|
|
105 style.
|
|
106 .TP
|
|
107 .IR \-r " | " \-revert
|
|
108 reverse operation: convert (or patch) hexdump into binary.
|
|
109 If not writing to stdout, xxd writes into its output file without truncating
|
|
110 it. Use the combination
|
|
111 .I \-r \-p
|
|
112 to read plain hexadecimal dumps without line number information and without a
|
|
113 particular column layout. Additional Whitespace and line-breaks are allowed
|
|
114 anywhere.
|
|
115 .TP
|
|
116 .I \-seek offset
|
|
117 When used after
|
|
118 .I \-r
|
|
119 : revert with
|
|
120 .RI < offset >
|
|
121 added to file positions found in hexdump.
|
|
122 .TP
|
|
123 .I \-s [\+][\-]seek
|
|
124 start at
|
|
125 .RI < seek >
|
|
126 bytes abs. (or rel.) infile offset.
|
|
127 \fI\+ \fRindicates that the seek is relative to the current stdin file position
|
|
128 (meaningless when not reading from stdin). \fI\- \fRindicates that the seek
|
|
129 should be that many characters from the end of the input (or if combined with
|
|
130 \fI \+ \fR: before the current stdin file position).
|
|
131 Without \-s option, xxd starts at the current file position.
|
|
132 .TP
|
|
133 .I \-u
|
|
134 use upper case hex letters. Default is lower case.
|
|
135 .TP
|
|
136 .IR \-v " | " \-version
|
|
137 show version string.
|
|
138 .SH CAVEATS
|
|
139 .PP
|
|
140 .I xxd \-r
|
|
141 has some builtin magic while evaluating line number information.
|
|
142 If the ouput file is seekable, then the linenumbers at the start of each
|
|
143 hexdump line may be out of order, lines may be missing, or overlapping. In
|
|
144 these cases xxd will lseek(2) to the next position. If the output file is not
|
|
145 seekable, only gaps are allowed, which will be filled by null-bytes.
|
|
146 .PP
|
|
147 .I xxd \-r
|
|
148 never generates parse errors. Garbage is silently skipped.
|
|
149 .PP
|
|
150 When editing hexdumps, please note that
|
|
151 .I xxd \-r
|
|
152 skips everything on the input line after reading enough columns of hexadecimal
|
|
153 data (see option \-c). This also means, that changes to the printable ascii (or
|
|
154 ebcdic) columns are always ignored. Reverting a plain (or postscript) style
|
|
155 hexdump with xxd \-r \-p does not depend on the correct number of columns. Here an thing that looks like a pair of hex-digits is interpreted.
|
|
156 .PP
|
|
157 Note the difference between
|
|
158 .br
|
|
159 \fI% xxd \-i file\fR
|
|
160 .br
|
|
161 and
|
|
162 .br
|
|
163 \fI% xxd \-i \< file\fR
|
|
164 .PP
|
|
165 .I xxd \-s \+seek
|
|
166 may be different from
|
|
167 .I xxd \-s seek
|
|
168 , as lseek(2) is used to "rewind" input. A '+'
|
|
169 makes a difference if the input source is stdin, and if stdin's file position
|
|
170 is not at the start of the file by the time xxd is started and given its input.
|
|
171 The following examples may help to clarify (or further confuse!)...
|
|
172 .PP
|
|
173 Rewind stdin before reading; needed because the `cat' has already read to the
|
|
174 end of stdin.
|
|
175 .br
|
|
176 \fI% sh \-c 'cat > plain_copy; xxd \-s 0 > hex_copy' < file
|
|
177 .PP
|
|
178 Hexdump from file position 0x480 (=1024+128) onwards.
|
|
179 The `+' sign means "relative to the current position", thus the `128' adds to
|
|
180 the 1k where dd left off.
|
|
181 .br
|
|
182 \fI% sh \-c 'dd of=plain_snippet bs=1k count=1; xxd \-s +128 > hex_snippet' < file
|
|
183 .PP
|
|
184 Hexdump from file position 0x100 ( = 1024-768) on.
|
|
185 .br
|
|
186 \fI% sh \-c 'dd of=plain_snippet bs=1k count=1; xxd \-s +-768 > hex_snippet' < file
|
|
187 .PP
|
|
188 However, this is a rare situation and the use of `+' is rarely needed.
|
|
189 the author prefers to monitor the effect of xxd with strace(1) or truss(1), whenever \-s is used.
|
|
190 .SH EXAMPLES
|
|
191 .PP
|
|
192 .br
|
|
193 Print everything but the first three lines (hex 0x30 bytes) of
|
|
194 .B file
|
|
195 \.
|
|
196 .br
|
|
197 \fI% xxd \-s 0x30 file
|
|
198 .PP
|
|
199 .br
|
|
200 Print 3 lines (hex 0x30 bytes) from the end of
|
|
201 .B file
|
|
202 \.
|
|
203 .br
|
|
204 \fI% xxd \-s \-0x30 file
|
|
205 .PP
|
|
206 .br
|
|
207 Print 120 bytes as continuous hexdump with 40 octets per line.
|
|
208 .br
|
|
209 \fI% xxd \-l 120 \-ps \-c 20 xxd.1\fR
|
|
210 .br
|
|
211 2e544820585844203120224d616e75616c207061
|
|
212 .br
|
|
213 676520666f7220787864220a2e5c220a2e5c2220
|
|
214 .br
|
|
215 32317374204d617920313939360a2e5c22204d61
|
|
216 .br
|
|
217 6e207061676520617574686f723a0a2e5c222020
|
|
218 .br
|
|
219 2020546f6e79204e7567656e74203c746f6e7940
|
|
220 .br
|
|
221 7363746e7567656e2e7070702e67752e6564752e
|
|
222 .br
|
|
223
|
|
224 .br
|
|
225 Hexdump the first 120 bytes of this man page with 12 octets per line.
|
|
226 .br
|
|
227 \fI% xxd \-l 120 \-c 12 xxd.1\fR
|
|
228 .br
|
|
229 0000000: 2e54 4820 5858 4420 3120 224d .TH XXD 1 "M
|
|
230 .br
|
|
231 000000c: 616e 7561 6c20 7061 6765 2066 anual page f
|
|
232 .br
|
|
233 0000018: 6f72 2078 7864 220a 2e5c 220a or xxd"..\\".
|
|
234 .br
|
|
235 0000024: 2e5c 2220 3231 7374 204d 6179 .\\" 21st May
|
|
236 .br
|
|
237 0000030: 2031 3939 360a 2e5c 2220 4d61 1996..\\" Ma
|
|
238 .br
|
|
239 000003c: 6e20 7061 6765 2061 7574 686f n page autho
|
|
240 .br
|
|
241 0000048: 723a 0a2e 5c22 2020 2020 546f r:..\\" To
|
|
242 .br
|
|
243 0000054: 6e79 204e 7567 656e 7420 3c74 ny Nugent <t
|
|
244 .br
|
|
245 0000060: 6f6e 7940 7363 746e 7567 656e ony@sctnugen
|
|
246 .br
|
|
247 000006c: 2e70 7070 2e67 752e 6564 752e .ppp.gu.edu.
|
|
248 .PP
|
|
249 .br
|
|
250 Display just the date from the file xxd.1
|
|
251 .br
|
|
252 \fI% xxd \-s 0x28 \-l 12 \-c 12 xxd.1\fR
|
|
253 .br
|
|
254 0000028: 3231 7374 204d 6179 2031 3939 21st May 199
|
|
255 .PP
|
|
256 .br
|
|
257 Copy
|
|
258 .B input_file
|
|
259 to
|
|
260 .B output_file
|
|
261 and prepend 100 bytes of value 0x00.
|
|
262 .br
|
|
263 \fI% xxd input_file | xxd \-r \-s 100 \> output_file\fR
|
|
264 .br
|
|
265
|
|
266 .br
|
|
267 Patch the date in the file xxd.1
|
|
268 .br
|
|
269 \fI% echo '0000029: 3574 68' | xxd \-r \- xxd.1\fR
|
|
270 .br
|
|
271 \fI% xxd \-s 0x28 \-l 12 \-c 12 xxd.1\fR
|
|
272 .br
|
|
273 0000028: 3235 7468 204d 6179 2031 3939 25th May 199
|
|
274 .PP
|
|
275 .br
|
|
276 Create a 65537 byte file with all bytes 0x00,
|
|
277 except for the last one which is 'A' (hex 0x41).
|
|
278 .br
|
|
279 \fI% echo '010000: 41' | xxd \-r \> file\fR
|
|
280 .PP
|
|
281 .br
|
|
282 Hexdump this file with autoskip.
|
|
283 .br
|
|
284 \fI% xxd \-a \-c 12 file\fR
|
|
285 .br
|
|
286 0000000: 0000 0000 0000 0000 0000 0000 ............
|
|
287 .br
|
|
288 *
|
|
289 .br
|
|
290 000fffc: 0000 0000 40 ....A
|
|
291 .PP
|
|
292 Create a 1 byte file containing a single 'A' character.
|
|
293 The number after '\-r \-s' adds to the linenumbers found in the file;
|
|
294 in effect, the leading bytes are suppressed.
|
|
295 .br
|
|
296 \fI% echo '010000: 41' | xxd \-r \-s \-0x10000 \> file\fR
|
|
297 .PP
|
|
298 Use xxd as a filter within an editor such as
|
|
299 .B vim(1)
|
|
300 to hexdump a region marked between `a' and `z'.
|
|
301 .br
|
|
302 \fI:'a,'z!xxd\fR
|
|
303 .PP
|
|
304 Use xxd as a filter within an editor such as
|
|
305 .B vim(1)
|
|
306 to recover a binary hexdump marked between `a' and `z'.
|
|
307 .br
|
|
308 \fI:'a,'z!xxd \-r\fR
|
|
309 .PP
|
|
310 Use xxd as a filter within an editor such as
|
|
311 .B vim(1)
|
|
312 to recover one line of a hexdump. Move the cursor over the line and type:
|
|
313 .br
|
|
314 \fI!!xxd \-r\fR
|
|
315 .PP
|
|
316 Read single characters from a serial line
|
|
317 .br
|
|
318 \fI% xxd \-c1 < /dev/term/b &\fR
|
|
319 .br
|
|
320 \fI% stty < /dev/term/b \-echo \-opost \-isig \-icanon min 1\fR
|
|
321 .br
|
|
322 \fI% echo \-n foo > /dev/term/b\fR
|
|
323 .PP
|
|
324 .SH "RETURN VALUES"
|
|
325 The following error values are returned:
|
|
326 .TP
|
|
327 0
|
|
328 no errors encountered.
|
|
329 .TP
|
|
330 \-1
|
|
331 operation not supported (
|
|
332 .I xxd \-r \-i
|
|
333 still impossible).
|
|
334 .TP
|
|
335 1
|
|
336 error while parsing options.
|
|
337 .TP
|
|
338 2
|
|
339 problems with input file.
|
|
340 .TP
|
|
341 3
|
|
342 problems with output file.
|
|
343 .TP
|
|
344 4,5
|
|
345 desired seek position is unreachable.
|
|
346 .SH "SEE ALSO"
|
|
347 uuencode(1), uudecode(1), patch(1)
|
|
348 .br
|
|
349 .SH WARNINGS
|
|
350 The tools weirdness matches its creators brain.
|
|
351 Use entirely at your own risk. Copy files. Trace it. Become a wizard.
|
|
352 .br
|
|
353 .SH VERSION
|
|
354 This manual page documents xxd version 1.7
|
|
355 .SH AUTHOR
|
|
356 .br
|
|
357 (c) 1990-1997 by Juergen Weigert
|
|
358 .br
|
|
359 <jnweiger@informatik.uni-erlangen.de>
|
|
360 .LP
|
|
361 Distribute freely and credit me,
|
|
362 .br
|
|
363 make money and share with me,
|
|
364 .br
|
|
365 lose money and don't ask me.
|
|
366 .PP
|
|
367 Manual page started by Tony Nugent
|
|
368 .br
|
|
369 <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au>
|
|
370 .br
|
|
371 Small changes by Bram Moolenaar.
|
|
372 Edited by Juergen Weigert.
|
|
373 .PP
|