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