Mercurial > vim
annotate runtime/doc/xxd.man @ 17724:76fba68d1c67 v8.1.1859
patch 8.1.1859: timer test sometimes fails on Mac
commit https://github.com/vim/vim/commit/427dddf014fea1326ea7f8c0951b0667dc037409
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 16 21:22:41 2019 +0200
patch 8.1.1859: timer test sometimes fails on Mac
Problem: Timer test sometimes fails on Mac.
Solution: Show more info when it fails.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Aug 2019 21:30:03 +0200 |
parents | 362b27e3f702 |
children | 2f854597399f |
rev | line source |
---|---|
6918 | 1 XXD(1) General Commands Manual XXD(1) |
7 | 2 |
3 | |
4 | |
5 NAME | |
6 xxd - make a hexdump or do the reverse. | |
7 | |
8 SYNOPSIS | |
9 xxd -h[elp] | |
10 xxd [options] [infile [outfile]] | |
11 xxd -r[evert] [options] [infile [outfile]] | |
12 | |
13 DESCRIPTION | |
36 | 14 xxd creates a hex dump of a given file or standard input. It can also |
15 convert a hex dump back to its original binary form. Like uuencode(1) | |
16 and uudecode(1) it allows the transmission of binary data in a `mail- | |
6918 | 17 safe' ASCII representation, but has the advantage of decoding to stan‐ |
36 | 18 dard output. Moreover, it can be used to perform binary file patching. |
7 | 19 |
20 OPTIONS | |
6918 | 21 If no infile is given, standard input is read. If infile is specified |
22 as a `-' character, then input is taken from standard input. If no | |
36 | 23 outfile is given (or a `-' character is in its place), results are sent |
24 to standard output. | |
7 | 25 |
6918 | 26 Note that a "lazy" parser is used which does not check for more than |
27 the first option letter, unless the option is followed by a parameter. | |
28 Spaces between a single option letter and its parameter are optional. | |
36 | 29 Parameters to options can be specified in decimal, hexadecimal or octal |
30 notation. Thus -c8, -c 8, -c 010 and -cols 8 are all equivalent. | |
7 | 31 |
32 -a | -autoskip | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
33 Toggle autoskip: A single '*' replaces nul-lines. Default off. |
7 | 34 |
35 -b | -bits | |
36 | 36 Switch to bits (binary digits) dump, rather than hexdump. This |
37 option writes octets as eight digits "1"s and "0"s instead of a | |
38 normal hexadecimal dump. Each line is preceded by a line number | |
6918 | 39 in hexadecimal and followed by an ascii (or ebcdic) representa‐ |
36 | 40 tion. The command line switches -r, -p, -i do not work with this |
41 mode. | |
7 | 42 |
43 -c cols | -cols cols | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
44 Format <cols> octets per line. Default 16 (-i: 12, -ps: 30, -b: |
36 | 45 6). Max 256. |
7 | 46 |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
47 -C | -capitalize |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
48 Capitalize variable names in C include file style, when using |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
49 -i. |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
50 |
7 | 51 -E | -EBCDIC |
36 | 52 Change the character encoding in the righthand column from ASCII |
53 to EBCDIC. This does not change the hexadecimal representation. | |
54 The option is meaningless in combinations with -r, -p or -i. | |
7 | 55 |
6918 | 56 -e Switch to little-endian hexdump. This option treats byte groups |
57 as words in little-endian byte order. The default grouping of 4 | |
58 bytes may be changed using -g. This option only applies to hex‐ | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
59 dump, leaving the ASCII (or EBCDIC) representation unchanged. |
6918 | 60 The command line switches -r, -p, -i do not work with this mode. |
61 | |
7 | 62 -g bytes | -groupsize bytes |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
63 Separate the output of every <bytes> bytes (two hex characters |
6918 | 64 or eight bit-digits each) by a whitespace. Specify -g 0 to sup‐ |
65 press grouping. <Bytes> defaults to 2 in normal mode, 4 in lit‐ | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
66 tle-endian mode and 1 in bits mode. Grouping does not apply to |
6918 | 67 postscript or include style. |
7 | 68 |
69 -h | -help | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
70 Print a summary of available commands and exit. No hex dumping |
36 | 71 is performed. |
7 | 72 |
73 -i | -include | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
74 Output in C include file style. A complete static array defini‐ |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
75 tion is written (named after the input file), unless xxd reads |
36 | 76 from stdin. |
7 | 77 |
78 -l len | -len len | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
79 Stop after writing <len> octets. |
7 | 80 |
6918 | 81 -o offset |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
82 Add <offset> to the displayed file position. |
6918 | 83 |
7 | 84 -p | -ps | -postscript | -plain |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
85 Output in postscript continuous hexdump style. Also known as |
36 | 86 plain hexdump style. |
7 | 87 |
88 -r | -revert | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
89 Reverse operation: convert (or patch) hexdump into binary. If |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
90 not writing to stdout, xxd writes into its output file without |
6918 | 91 truncating it. Use the combination -r -p to read plain hexadeci‐ |
92 mal dumps without line number information and without a particu‐ | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
93 lar column layout. Additional Whitespace and line-breaks are |
36 | 94 allowed anywhere. |
7 | 95 |
96 -seek offset | |
218 | 97 When used after -r: revert with <offset> added to file positions |
98 found in hexdump. | |
7 | 99 |
100 -s [+][-]seek | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
101 Start at <seek> bytes abs. (or rel.) infile offset. + indicates |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
102 that the seek is relative to the current stdin file position |
1126 | 103 (meaningless when not reading from stdin). - indicates that the |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
104 seek should be that many characters from the end of the input |
1126 | 105 (or if combined with +: before the current stdin file position). |
106 Without -s option, xxd starts at the current file position. | |
7 | 107 |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
108 -u Use upper case hex letters. Default is lower case. |
7 | 109 |
110 -v | -version | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
111 Show version string. |
7 | 112 |
36 | 113 CAVEATS |
114 xxd -r has some builtin magic while evaluating line number information. | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
115 If the output file is seekable, then the linenumbers at the start of |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
116 each hexdump line may be out of order, lines may be missing, or over‐ |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
117 lapping. In these cases xxd will lseek(2) to the next position. If the |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
118 output file is not seekable, only gaps are allowed, which will be |
36 | 119 filled by null-bytes. |
7 | 120 |
36 | 121 xxd -r never generates parse errors. Garbage is silently skipped. |
7 | 122 |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
123 When editing hexdumps, please note that xxd -r skips everything on the |
36 | 124 input line after reading enough columns of hexadecimal data (see option |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
125 -c). This also means, that changes to the printable ascii (or ebcdic) |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
126 columns are always ignored. Reverting a plain (or postscript) style |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
127 hexdump with xxd -r -p does not depend on the correct number of col‐ |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
128 umns. Here anything that looks like a pair of hex-digits is inter‐ |
36 | 129 preted. |
7 | 130 |
131 Note the difference between | |
132 % xxd -i file | |
133 and | |
134 % xxd -i < file | |
135 | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
136 xxd -s +seek may be different from xxd -s seek, as lseek(2) is used to |
36 | 137 "rewind" input. A '+' makes a difference if the input source is stdin, |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
138 and if stdin's file position is not at the start of the file by the |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
139 time xxd is started and given its input. The following examples may |
36 | 140 help to clarify (or further confuse!)... |
7 | 141 |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
142 Rewind stdin before reading; needed because the `cat' has already read |
36 | 143 to the end of stdin. |
810 | 144 % sh -c "cat > plain_copy; xxd -s 0 > hex_copy" < file |
7 | 145 |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
146 Hexdump from file position 0x480 (=1024+128) onwards. The `+' sign |
36 | 147 means "relative to the current position", thus the `128' adds to the 1k |
148 where dd left off. | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
149 % sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +128 > hex_snippet" |
36 | 150 < file |
7 | 151 |
152 Hexdump from file position 0x100 ( = 1024-768) on. | |
810 | 153 % sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +-768 > hex_snippet" |
36 | 154 < file |
7 | 155 |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
156 However, this is a rare situation and the use of `+' is rarely needed. |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
157 The author prefers to monitor the effect of xxd with strace(1) or |
36 | 158 truss(1), whenever -s is used. |
7 | 159 |
160 EXAMPLES | |
810 | 161 Print everything but the first three lines (hex 0x30 bytes) of file. |
7 | 162 % xxd -s 0x30 file |
163 | |
810 | 164 Print 3 lines (hex 0x30 bytes) from the end of file. |
7 | 165 % xxd -s -0x30 file |
166 | |
1126 | 167 Print 120 bytes as continuous hexdump with 20 octets per line. |
7 | 168 % xxd -l 120 -ps -c 20 xxd.1 |
36 | 169 2e54482058584420312022417567757374203139 |
170 39362220224d616e75616c207061676520666f72 | |
171 20787864220a2e5c220a2e5c222032317374204d | |
172 617920313939360a2e5c22204d616e2070616765 | |
173 20617574686f723a0a2e5c2220202020546f6e79 | |
174 204e7567656e74203c746f6e79407363746e7567 | |
7 | 175 |
36 | 176 Hexdump the first 120 bytes of this man page with 12 octets per line. |
7 | 177 % xxd -l 120 -c 12 xxd.1 |
36 | 178 0000000: 2e54 4820 5858 4420 3120 2241 .TH XXD 1 "A |
179 000000c: 7567 7573 7420 3139 3936 2220 ugust 1996" | |
180 0000018: 224d 616e 7561 6c20 7061 6765 "Manual page | |
181 0000024: 2066 6f72 2078 7864 220a 2e5c for xxd"..\ | |
182 0000030: 220a 2e5c 2220 3231 7374 204d "..\" 21st M | |
183 000003c: 6179 2031 3939 360a 2e5c 2220 ay 1996..\" | |
184 0000048: 4d61 6e20 7061 6765 2061 7574 Man page aut | |
185 0000054: 686f 723a 0a2e 5c22 2020 2020 hor:..\" | |
186 0000060: 546f 6e79 204e 7567 656e 7420 Tony Nugent | |
187 000006c: 3c74 6f6e 7940 7363 746e 7567 <tony@sctnug | |
7 | 188 |
189 Display just the date from the file xxd.1 | |
36 | 190 % xxd -s 0x36 -l 13 -c 13 xxd.1 |
191 0000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996 | |
7 | 192 |
36 | 193 Copy input_file to output_file and prepend 100 bytes of value 0x00. |
7 | 194 % xxd input_file | xxd -r -s 100 > output_file |
195 | |
196 Patch the date in the file xxd.1 | |
810 | 197 % echo "0000037: 3574 68" | xxd -r - xxd.1 |
36 | 198 % xxd -s 0x36 -l 13 -c 13 xxd.1 |
199 0000036: 3235 7468 204d 6179 2031 3939 36 25th May 1996 | |
7 | 200 |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
201 Create a 65537 byte file with all bytes 0x00, except for the last one |
36 | 202 which is 'A' (hex 0x41). |
810 | 203 % echo "010000: 41" | xxd -r > file |
7 | 204 |
205 Hexdump this file with autoskip. | |
206 % xxd -a -c 12 file | |
207 0000000: 0000 0000 0000 0000 0000 0000 ............ | |
208 * | |
209 000fffc: 0000 0000 40 ....A | |
210 | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
211 Create a 1 byte file containing a single 'A' character. The number |
36 | 212 after '-r -s' adds to the linenumbers found in the file; in effect, the |
213 leading bytes are suppressed. | |
810 | 214 % echo "010000: 41" | xxd -r -s -0x10000 > file |
7 | 215 |
36 | 216 Use xxd as a filter within an editor such as vim(1) to hexdump a region |
217 marked between `a' and `z'. | |
7 | 218 :'a,'z!xxd |
219 | |
36 | 220 Use xxd as a filter within an editor such as vim(1) to recover a binary |
221 hexdump marked between `a' and `z'. | |
7 | 222 :'a,'z!xxd -r |
223 | |
36 | 224 Use xxd as a filter within an editor such as vim(1) to recover one line |
225 of a hexdump. Move the cursor over the line and type: | |
7 | 226 !!xxd -r |
227 | |
228 Read single characters from a serial line | |
229 % xxd -c1 < /dev/term/b & | |
230 % stty < /dev/term/b -echo -opost -isig -icanon min 1 | |
231 % echo -n foo > /dev/term/b | |
232 | |
233 RETURN VALUES | |
234 The following error values are returned: | |
235 | |
236 0 no errors encountered. | |
237 | |
36 | 238 -1 operation not supported ( xxd -r -i still impossible). |
7 | 239 |
240 1 error while parsing options. | |
241 | |
242 2 problems with input file. | |
243 | |
244 3 problems with output file. | |
245 | |
246 4,5 desired seek position is unreachable. | |
247 | |
248 SEE ALSO | |
249 uuencode(1), uudecode(1), patch(1) | |
250 | |
251 WARNINGS | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6918
diff
changeset
|
252 The tools weirdness matches its creators brain. Use entirely at your |
36 | 253 own risk. Copy files. Trace it. Become a wizard. |
7 | 254 |
255 VERSION | |
256 This manual page documents xxd version 1.7 | |
257 | |
258 AUTHOR | |
259 (c) 1990-1997 by Juergen Weigert | |
260 <jnweiger@informatik.uni-erlangen.de> | |
261 | |
262 Distribute freely and credit me, | |
263 make money and share with me, | |
264 lose money and don't ask me. | |
265 | |
266 Manual page started by Tony Nugent | |
267 <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au> | |
36 | 268 Small changes by Bram Moolenaar. Edited by Juergen Weigert. |
7 | 269 |
36 | 270 Manual page for xxd August 1996 XXD(1) |