Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 9 | \- make a hex dump or do the reverse. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 4317d9b | 2005-03-18 20:25:31 +0000 | [diff] [blame] | 24 | .BR uuencode (1) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 25 | and |
Bram Moolenaar | 4317d9b | 2005-03-18 20:25:31 +0000 | [diff] [blame] | 26 | .BR uudecode (1) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 60 | Toggle autoskip: A single '*' replaces NUL-lines. Default off. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 61 | .TP |
| 62 | .IR \-b " | " \-bits |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 63 | Switch to bits (binary digits) dump, rather than hex dump. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 64 | This option writes octets as eight digits "1"s and "0"s instead of a normal |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 65 | hexadecimal dump. Each line is preceded by a line number in hexadecimal and |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 66 | followed by an ASCII (or EBCDIC) representation. The command line switches |
tristhaus | 85f4521 | 2023-10-06 19:51:13 +0200 | [diff] [blame] | 67 | \-p, \-i do not work with this mode. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 68 | .TP |
| 69 | .IR "\-c cols " | " \-cols cols" |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 70 | Format |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 71 | .RI < cols > |
| 72 | octets per line. Default 16 (\-i: 12, \-ps: 30, \-b: 6). Max 256. |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 73 | No maximum for \-ps. With \-ps, 0 results in one long line of output. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 74 | .TP |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 75 | .IR \-C " | " \-capitalize |
| 76 | Capitalize variable names in C include file style, when using \-i. |
| 77 | .TP |
Lennard Hofmann | 6779719 | 2024-05-10 14:17:26 +0200 | [diff] [blame] | 78 | .I \-d |
| 79 | show offset in decimal instead of hex. |
| 80 | .TP |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 81 | .IR \-E " | " \-EBCDIC |
| 82 | Change the character encoding in the righthand column from ASCII to EBCDIC. |
| 83 | This does not change the hexadecimal representation. The option is |
| 84 | meaningless in combinations with \-r, \-p or \-i. |
| 85 | .TP |
Bram Moolenaar | 4dcdf29 | 2015-03-05 17:51:15 +0100 | [diff] [blame] | 86 | .IR \-e |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 87 | Switch to little-endian hex dump. |
Bram Moolenaar | 4dcdf29 | 2015-03-05 17:51:15 +0100 | [diff] [blame] | 88 | This option treats byte groups as words in little-endian byte order. |
| 89 | The default grouping of 4 bytes may be changed using |
| 90 | .RI "" \-g . |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 91 | This option only applies to the hex dump, leaving the ASCII (or EBCDIC) |
Bram Moolenaar | 4dcdf29 | 2015-03-05 17:51:15 +0100 | [diff] [blame] | 92 | representation unchanged. |
| 93 | The command line switches |
| 94 | \-r, \-p, \-i do not work with this mode. |
| 95 | .TP |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 96 | .IR "\-g bytes " | " \-groupsize bytes" |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 97 | Separate the output of every |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 98 | .RI < bytes > |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 99 | bytes (two hex characters or eight bit digits each) by a whitespace. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 100 | Specify |
| 101 | .I \-g 0 |
| 102 | to suppress grouping. |
| 103 | .RI < Bytes "> defaults to " 2 |
Bram Moolenaar | 4dcdf29 | 2015-03-05 17:51:15 +0100 | [diff] [blame] | 104 | in normal mode, \fI4\fP in little-endian mode and \fI1\fP in bits mode. |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 105 | Grouping does not apply to PostScript or include style. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 106 | .TP |
| 107 | .IR \-h " | " \-help |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 108 | Print a summary of available commands and exit. No hex dumping is performed. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 109 | .TP |
| 110 | .IR \-i " | " \-include |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 111 | Output in C include file style. A complete static array definition is written |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 112 | (named after the input file), unless xxd reads from stdin. |
| 113 | .TP |
| 114 | .IR "\-l len " | " \-len len" |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 115 | Stop after writing |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 116 | .RI < len > |
| 117 | octets. |
| 118 | .TP |
David Gow | 83e1180 | 2022-06-29 20:24:49 +0100 | [diff] [blame] | 119 | .I "\-n name " | " \-name name" |
| 120 | Override the variable name output when \-i is used. The array is named |
| 121 | \fIname\fP and the length is named \fIname\fP_len. |
| 122 | .TP |
Bram Moolenaar | 4dcdf29 | 2015-03-05 17:51:15 +0100 | [diff] [blame] | 123 | .I \-o offset |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 124 | Add |
Bram Moolenaar | 4dcdf29 | 2015-03-05 17:51:15 +0100 | [diff] [blame] | 125 | .RI < offset > |
| 126 | to the displayed file position. |
| 127 | .TP |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 128 | .IR \-p " | " \-ps " | " \-postscript " | " \-plain |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 129 | Output in PostScript continuous hex dump style. Also known as plain hex dump |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 130 | style. |
| 131 | .TP |
| 132 | .IR \-r " | " \-revert |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 133 | Reverse operation: convert (or patch) hex dump into binary. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 134 | If not writing to stdout, xxd writes into its output file without truncating |
| 135 | it. Use the combination |
| 136 | .I \-r \-p |
| 137 | to read plain hexadecimal dumps without line number information and without a |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 138 | particular column layout. Additional whitespace and line breaks are allowed |
tristhaus | 85f4521 | 2023-10-06 19:51:13 +0200 | [diff] [blame] | 139 | anywhere. Use the combination |
| 140 | .I \-r \-b |
| 141 | to read a bits dump instead of a hex dump. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 142 | .TP |
K.Takata | f6fc255 | 2023-09-01 18:41:04 +0200 | [diff] [blame] | 143 | .IR \-R " " when |
Lennard Hofmann | 6779719 | 2024-05-10 14:17:26 +0200 | [diff] [blame] | 144 | In the output the hex-value and the value are both colored with the same color |
Christian Brabandt | b74ebfc | 2023-10-03 16:55:18 +0200 | [diff] [blame] | 145 | depending on the hex-value. Mostly helping to differentiate printable and |
| 146 | non-printable characters. |
K.Takata | f6fc255 | 2023-09-01 18:41:04 +0200 | [diff] [blame] | 147 | .I \fIwhen\fP |
Aapo Rantalainen | e2528ae | 2023-08-31 17:58:13 +0200 | [diff] [blame] | 148 | is |
Lennard Hofmann | 6779719 | 2024-05-10 14:17:26 +0200 | [diff] [blame] | 149 | .BR never ", " always ", or " auto " (default: auto). |
Christian Brabandt | b74ebfc | 2023-10-03 16:55:18 +0200 | [diff] [blame] | 150 | When the |
| 151 | .BR $NO_COLOR |
| 152 | environment variable is set, colorization will be disabled. |
Aapo Rantalainen | e2528ae | 2023-08-31 17:58:13 +0200 | [diff] [blame] | 153 | .TP |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 154 | .I \-seek offset |
| 155 | When used after |
Bram Moolenaar | 4317d9b | 2005-03-18 20:25:31 +0000 | [diff] [blame] | 156 | .IR \-r : |
| 157 | revert with |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 158 | .RI < offset > |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 159 | added to file positions found in hex dump. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 160 | .TP |
Bram Moolenaar | 4317d9b | 2005-03-18 20:25:31 +0000 | [diff] [blame] | 161 | .I \-s [+][\-]seek |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 162 | Start at |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 163 | .RI < seek > |
| 164 | bytes abs. (or rel.) infile offset. |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 165 | \fI+ \fRindicates that the seek is relative to the current stdin file position |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 166 | (meaningless when not reading from stdin). \fI\- \fRindicates that the seek |
| 167 | should be that many characters from the end of the input (or if combined with |
Bram Moolenaar | 4317d9b | 2005-03-18 20:25:31 +0000 | [diff] [blame] | 168 | \fI+\fR: before the current stdin file position). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 169 | Without \-s option, xxd starts at the current file position. |
| 170 | .TP |
| 171 | .I \-u |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 172 | Use upper-case hex letters. Default is lower-case. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 173 | .TP |
| 174 | .IR \-v " | " \-version |
Bram Moolenaar | 79cf7c0 | 2018-04-03 14:21:16 +0200 | [diff] [blame] | 175 | Show version string. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 176 | .SH CAVEATS |
| 177 | .PP |
| 178 | .I xxd \-r |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 179 | has some built-in magic while evaluating line number information. |
| 180 | If the output file is seekable, then the line numbers at the start of each |
| 181 | hex dump line may be out of order, lines may be missing, or overlapping. In |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 182 | these cases xxd will lseek(2) to the next position. If the output file is not |
| 183 | seekable, only gaps are allowed, which will be filled by null-bytes. |
| 184 | .PP |
| 185 | .I xxd \-r |
| 186 | never generates parse errors. Garbage is silently skipped. |
| 187 | .PP |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 188 | When editing hex dumps, please note that |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 189 | .I xxd \-r |
| 190 | skips everything on the input line after reading enough columns of hexadecimal |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 191 | data (see option \-c). This also means that changes to the printable ASCII (or |
| 192 | EBCDIC) columns are always ignored. Reverting a plain (or PostScript) style |
| 193 | hex dump 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. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 194 | .PP |
| 195 | Note the difference between |
| 196 | .br |
| 197 | \fI% xxd \-i file\fR |
| 198 | .br |
| 199 | and |
| 200 | .br |
Bram Moolenaar | 4317d9b | 2005-03-18 20:25:31 +0000 | [diff] [blame] | 201 | \fI% xxd \-i < file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 202 | .PP |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 203 | .I xxd \-s +seek |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 204 | may be different from |
Bram Moolenaar | 4317d9b | 2005-03-18 20:25:31 +0000 | [diff] [blame] | 205 | .IR "xxd \-s seek" , |
| 206 | as lseek(2) is used to "rewind" input. A '+' |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 207 | makes a difference if the input source is stdin, and if stdin's file position |
| 208 | is not at the start of the file by the time xxd is started and given its input. |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 209 | The following examples may help to clarify (or further confuse!): |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 210 | .PP |
| 211 | Rewind stdin before reading; needed because the `cat' has already read to the |
| 212 | end of stdin. |
| 213 | .br |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 214 | \fI% sh \-c "cat > plain_copy; xxd \-s 0 > hex_copy" < file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 215 | .PP |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 216 | Hex dump from file position 0x480 (=1024+128) onwards. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 217 | The `+' sign means "relative to the current position", thus the `128' adds to |
| 218 | the 1k where dd left off. |
| 219 | .br |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 220 | \fI% sh \-c "dd of=plain_snippet bs=1k count=1; xxd \-s +128 > hex_snippet" < file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 221 | .PP |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 222 | Hex dump from file position 0x100 (=1024\-768) onwards. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 223 | .br |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 224 | \fI% sh \-c "dd of=plain_snippet bs=1k count=1; xxd \-s +\-768 > hex_snippet" < file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 225 | .PP |
| 226 | However, this is a rare situation and the use of `+' is rarely needed. |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 227 | The author prefers to monitor the effect of xxd with strace(1) or truss(1), whenever \-s is used. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 228 | .SH EXAMPLES |
| 229 | .PP |
| 230 | .br |
| 231 | Print everything but the first three lines (hex 0x30 bytes) of |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 232 | .BR file . |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 233 | .br |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 234 | \fI% xxd \-s 0x30 file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 235 | .PP |
| 236 | .br |
| 237 | Print 3 lines (hex 0x30 bytes) from the end of |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 238 | .BR file . |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 239 | .br |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 240 | \fI% xxd \-s \-0x30 file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 241 | .PP |
| 242 | .br |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 243 | 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] | 244 | .br |
| 245 | \fI% xxd \-l 120 \-ps \-c 20 xxd.1\fR |
| 246 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 247 | 2e54482058584420312022417567757374203139 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 248 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 249 | 39362220224d616e75616c207061676520666f72 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 250 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 251 | 20787864220a2e5c220a2e5c222032317374204d |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 252 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 253 | 617920313939360a2e5c22204d616e2070616765 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 254 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 255 | 20617574686f723a0a2e5c2220202020546f6e79 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 256 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 257 | 204e7567656e74203c746f6e79407363746e7567 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 258 | .br |
| 259 | |
| 260 | .br |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 261 | 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] | 262 | .br |
| 263 | \fI% xxd \-l 120 \-c 12 xxd.1\fR |
| 264 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 265 | 0000000: 2e54 4820 5858 4420 3120 2241 .TH XXD 1 "A |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 266 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 267 | 000000c: 7567 7573 7420 3139 3936 2220 ugust 1996" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 268 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 269 | 0000018: 224d 616e 7561 6c20 7061 6765 "Manual page |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 270 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 271 | 0000024: 2066 6f72 2078 7864 220a 2e5c for xxd"..\\ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 272 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 273 | 0000030: 220a 2e5c 2220 3231 7374 204d "..\\" 21st M |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 274 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 275 | 000003c: 6179 2031 3939 360a 2e5c 2220 ay 1996..\\" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 276 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 277 | 0000048: 4d61 6e20 7061 6765 2061 7574 Man page aut |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 278 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 279 | 0000054: 686f 723a 0a2e 5c22 2020 2020 hor:..\\" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 280 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 281 | 0000060: 546f 6e79 204e 7567 656e 7420 Tony Nugent |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 282 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 283 | 000006c: 3c74 6f6e 7940 7363 746e 7567 <tony@sctnug |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 284 | .PP |
| 285 | .br |
| 286 | Display just the date from the file xxd.1 |
| 287 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 288 | \fI% xxd \-s 0x36 \-l 13 \-c 13 xxd.1\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 289 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 290 | 0000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 291 | .PP |
| 292 | .br |
| 293 | Copy |
| 294 | .B input_file |
| 295 | to |
| 296 | .B output_file |
| 297 | and prepend 100 bytes of value 0x00. |
| 298 | .br |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 299 | \fI% xxd input_file | xxd \-r \-s 100 > output_file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 300 | .br |
| 301 | |
| 302 | .br |
| 303 | Patch the date in the file xxd.1 |
| 304 | .br |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 305 | \fI% echo "0000037: 3574 68" | xxd \-r \- xxd.1\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 306 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 307 | \fI% xxd \-s 0x36 \-l 13 \-c 13 xxd.1\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 308 | .br |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 309 | 0000036: 3235 7468 204d 6179 2031 3939 36 25th May 1996 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 310 | .PP |
| 311 | .br |
| 312 | Create a 65537 byte file with all bytes 0x00, |
| 313 | except for the last one which is 'A' (hex 0x41). |
| 314 | .br |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 315 | \fI% echo "010000: 41" | xxd \-r > file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 316 | .PP |
| 317 | .br |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 318 | Hex dump this file with autoskip. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 319 | .br |
| 320 | \fI% xxd \-a \-c 12 file\fR |
| 321 | .br |
| 322 | 0000000: 0000 0000 0000 0000 0000 0000 ............ |
| 323 | .br |
| 324 | * |
| 325 | .br |
| 326 | 000fffc: 0000 0000 40 ....A |
| 327 | .PP |
| 328 | Create a 1 byte file containing a single 'A' character. |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 329 | The number after '\-r \-s' adds to the line numbers found in the file; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 330 | in effect, the leading bytes are suppressed. |
| 331 | .br |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 332 | \fI% echo "010000: 41" | xxd \-r \-s \-0x10000 > file\fR |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 333 | .PP |
| 334 | Use xxd as a filter within an editor such as |
| 335 | .B vim(1) |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 336 | to hex dump a region marked between `a' and `z'. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 337 | .br |
| 338 | \fI:'a,'z!xxd\fR |
| 339 | .PP |
| 340 | Use xxd as a filter within an editor such as |
| 341 | .B vim(1) |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 342 | to recover a binary hex dump marked between `a' and `z'. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 343 | .br |
| 344 | \fI:'a,'z!xxd \-r\fR |
| 345 | .PP |
| 346 | Use xxd as a filter within an editor such as |
| 347 | .B vim(1) |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 348 | to recover one line of a hex dump. Move the cursor over the line and type: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 349 | .br |
| 350 | \fI!!xxd \-r\fR |
| 351 | .PP |
| 352 | Read single characters from a serial line |
| 353 | .br |
| 354 | \fI% xxd \-c1 < /dev/term/b &\fR |
| 355 | .br |
| 356 | \fI% stty < /dev/term/b \-echo \-opost \-isig \-icanon min 1\fR |
| 357 | .br |
| 358 | \fI% echo \-n foo > /dev/term/b\fR |
| 359 | .PP |
| 360 | .SH "RETURN VALUES" |
| 361 | The following error values are returned: |
| 362 | .TP |
| 363 | 0 |
| 364 | no errors encountered. |
| 365 | .TP |
| 366 | \-1 |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 367 | operation not supported |
| 368 | \%(\c |
| 369 | .I \%xxd \-r \-i |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 370 | still impossible). |
| 371 | .TP |
| 372 | 1 |
| 373 | error while parsing options. |
| 374 | .TP |
| 375 | 2 |
| 376 | problems with input file. |
| 377 | .TP |
| 378 | 3 |
| 379 | problems with output file. |
| 380 | .TP |
| 381 | 4,5 |
| 382 | desired seek position is unreachable. |
| 383 | .SH "SEE ALSO" |
| 384 | uuencode(1), uudecode(1), patch(1) |
| 385 | .br |
| 386 | .SH WARNINGS |
Matthias Braun | 02551c9 | 2023-08-13 19:20:35 +0200 | [diff] [blame] | 387 | The tool's weirdness matches its creator's brain. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 388 | Use entirely at your own risk. Copy files. Trace it. Become a wizard. |
| 389 | .br |
| 390 | .SH VERSION |
| 391 | This manual page documents xxd version 1.7 |
| 392 | .SH AUTHOR |
| 393 | .br |
| 394 | (c) 1990-1997 by Juergen Weigert |
| 395 | .br |
Bram Moolenaar | 3991dab | 2006-03-27 17:01:56 +0000 | [diff] [blame] | 396 | <jnweiger@informatik.uni\-erlangen.de> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 397 | .LP |
| 398 | Distribute freely and credit me, |
| 399 | .br |
| 400 | make money and share with me, |
| 401 | .br |
| 402 | lose money and don't ask me. |
| 403 | .PP |
| 404 | Manual page started by Tony Nugent |
| 405 | .br |
| 406 | <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au> |
| 407 | .br |
| 408 | Small changes by Bram Moolenaar. |
| 409 | Edited by Juergen Weigert. |
| 410 | .PP |