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