589 lines
13 KiB
HTML
589 lines
13 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of XXD</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>XXD</H1>
|
|
Section: User Commands (1)<BR>Updated: August 1996<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
<I>xxd</I>
|
|
|
|
- make a hexdump or do the reverse.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>xxd</B>
|
|
|
|
-h[elp]
|
|
<BR>
|
|
|
|
<B>xxd</B>
|
|
|
|
[options] [infile [outfile]]
|
|
<BR>
|
|
|
|
<B>xxd</B>
|
|
|
|
-r[evert] [options] [infile [outfile]]
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<I>xxd</I>
|
|
|
|
creates a hex dump of a given file or standard input.
|
|
It can also convert a hex dump back to its original binary form.
|
|
Like
|
|
<B><A HREF="/cgi-bin/man/man2html?1+uuencode">uuencode</A></B>(1)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?1+uudecode">uudecode</A></B>(1)
|
|
|
|
it allows the transmission of binary data in a `mail-safe' ASCII representation,
|
|
but has the advantage of decoding to standard output.
|
|
Moreover, it can be used to perform binary file patching.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
If no
|
|
<I>infile</I>
|
|
|
|
is given, standard input is read.
|
|
If
|
|
<I>infile</I>
|
|
|
|
is specified as a
|
|
`<B>-</B>'
|
|
|
|
character, then input is taken from standard input.
|
|
If no
|
|
<I>outfile</I>
|
|
|
|
is given (or a
|
|
`<B>-</B>'
|
|
|
|
character is in its place), results are sent to standard output.
|
|
<P>
|
|
|
|
Note that a "lazy" parser is used which does not check for more than the first
|
|
option letter, unless the option is followed by a parameter.
|
|
Spaces between a single option letter and its parameter are optional.
|
|
Parameters to options can be specified in decimal, hexadecimal or octal
|
|
notation.
|
|
Thus
|
|
<B>-c8</B>,
|
|
|
|
<B>-c 8</B>,
|
|
|
|
<B>-c 010</B>
|
|
|
|
and
|
|
<B>-cols 8</B>
|
|
|
|
are all equivalent.
|
|
<P>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><I>-a</I> | <I>-autoskip</I>
|
|
|
|
<DD>
|
|
Toggle autoskip: A single '*' replaces nul-lines. Default off.
|
|
<DT id="2"><I>-b</I> | <I>-bits</I>
|
|
|
|
<DD>
|
|
Switch to bits (binary digits) dump, rather than hexdump.
|
|
This option writes octets as eight digits "1"s and "0"s instead of a normal
|
|
hexadecimal dump. Each line is preceded by a line number in hexadecimal and
|
|
followed by an ascii (or ebcdic) representation. The command line switches
|
|
-r, -p, -i do not work with this mode.
|
|
<DT id="3"><I>-c cols </I>|<I> -cols cols</I>
|
|
|
|
<DD>
|
|
Format
|
|
<<I>cols</I>>
|
|
|
|
octets per line. Default 16 (-i: 12, -ps: 30, -b: 6). Max 256.
|
|
<DT id="4"><I>-C</I> | <I>-capitalize</I>
|
|
|
|
<DD>
|
|
Capitalize variable names in C include file style, when using -i.
|
|
<DT id="5"><I>-E</I> | <I>-EBCDIC</I>
|
|
|
|
<DD>
|
|
Change the character encoding in the righthand column from ASCII to EBCDIC.
|
|
This does not change the hexadecimal representation. The option is
|
|
meaningless in combinations with -r, -p or -i.
|
|
<DT id="6"><I>-e</I>
|
|
|
|
<DD>
|
|
Switch to little-endian hexdump.
|
|
This option treats byte groups as words in little-endian byte order.
|
|
The default grouping of 4 bytes may be changed using
|
|
<I>-g</I>.
|
|
|
|
This option only applies to hexdump, leaving the ASCII (or EBCDIC)
|
|
representation unchanged.
|
|
The command line switches
|
|
-r, -p, -i do not work with this mode.
|
|
<DT id="7"><I>-g bytes </I>|<I> -groupsize bytes</I>
|
|
|
|
<DD>
|
|
Separate the output of every
|
|
<<I>bytes</I>>
|
|
|
|
bytes (two hex characters or eight bit-digits each) by a whitespace.
|
|
Specify
|
|
<I>-g 0</I>
|
|
|
|
to suppress grouping.
|
|
<<I>Bytes</I>> defaults to <I>2</I>
|
|
|
|
in normal mode, <I>4</I> in little-endian mode and <I>1</I> in bits mode.
|
|
Grouping does not apply to postscript or include style.
|
|
<DT id="8"><I>-h</I> | <I>-help</I>
|
|
|
|
<DD>
|
|
Print a summary of available commands and exit. No hex dumping is performed.
|
|
<DT id="9"><I>-i</I> | <I>-include</I>
|
|
|
|
<DD>
|
|
Output in C include file style. A complete static array definition is written
|
|
(named after the input file), unless xxd reads from stdin.
|
|
<DT id="10"><I>-l len </I>|<I> -len len</I>
|
|
|
|
<DD>
|
|
Stop after writing
|
|
<<I>len</I>>
|
|
|
|
octets.
|
|
<DT id="11"><I>-o offset</I>
|
|
|
|
<DD>
|
|
Add
|
|
<<I>offset</I>>
|
|
|
|
to the displayed file position.
|
|
<DT id="12"><I>-p</I> | <I>-ps</I> | <I>-postscript</I> | <I>-plain</I>
|
|
|
|
<DD>
|
|
Output in postscript continuous hexdump style. Also known as plain hexdump
|
|
style.
|
|
<DT id="13"><I>-r</I> | <I>-revert</I>
|
|
|
|
<DD>
|
|
Reverse operation: convert (or patch) hexdump into binary.
|
|
If not writing to stdout, xxd writes into its output file without truncating
|
|
it. Use the combination
|
|
<I>-r -p</I>
|
|
|
|
to read plain hexadecimal dumps without line number information and without a
|
|
particular column layout. Additional Whitespace and line-breaks are allowed
|
|
anywhere.
|
|
<DT id="14"><I>-seek offset</I>
|
|
|
|
<DD>
|
|
When used after
|
|
<I>-r</I>:
|
|
|
|
revert with
|
|
<<I>offset</I>>
|
|
|
|
added to file positions found in hexdump.
|
|
<DT id="15"><I>-s [+][-]seek</I>
|
|
|
|
<DD>
|
|
Start at
|
|
<<I>seek</I>>
|
|
|
|
bytes abs. (or rel.) infile offset.
|
|
<I>+ </I>indicates that the seek is relative to the current stdin file position
|
|
(meaningless when not reading from stdin). <I>- </I>indicates that the seek
|
|
should be that many characters from the end of the input (or if combined with
|
|
<I>+</I>: before the current stdin file position).
|
|
Without -s option, xxd starts at the current file position.
|
|
<DT id="16"><I>-u</I>
|
|
|
|
<DD>
|
|
Use upper case hex letters. Default is lower case.
|
|
<DT id="17"><I>-v</I> | <I>-version</I>
|
|
|
|
<DD>
|
|
Show version string.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>CAVEATS</H2>
|
|
|
|
<P>
|
|
|
|
<I>xxd -r</I>
|
|
|
|
has some builtin magic while evaluating line number information.
|
|
If the output file is seekable, then the linenumbers at the start of each
|
|
hexdump line may be out of order, lines may be missing, or overlapping. In
|
|
these cases xxd will <A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A>(2) to the next position. If the output file is not
|
|
seekable, only gaps are allowed, which will be filled by null-bytes.
|
|
<P>
|
|
|
|
<I>xxd -r</I>
|
|
|
|
never generates parse errors. Garbage is silently skipped.
|
|
<P>
|
|
|
|
When editing hexdumps, please note that
|
|
<I>xxd -r</I>
|
|
|
|
skips everything on the input line after reading enough columns of hexadecimal
|
|
data (see option -c). This also means, that changes to the printable ascii (or
|
|
ebcdic) columns are always ignored. Reverting a plain (or postscript) style
|
|
hexdump 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.
|
|
<P>
|
|
|
|
Note the difference between
|
|
<BR>
|
|
|
|
<I>% xxd -i file</I>
|
|
<BR>
|
|
|
|
and
|
|
<BR>
|
|
|
|
<I>% xxd -i < file</I>
|
|
<P>
|
|
|
|
<I>xxd -s +seek</I>
|
|
|
|
may be different from
|
|
<I>xxd -s seek</I>,
|
|
|
|
as <A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A>(2) is used to "rewind" input. A '+'
|
|
makes a difference if the input source is stdin, and if stdin's file position
|
|
is not at the start of the file by the time xxd is started and given its input.
|
|
The following examples may help to clarify (or further confuse!)...
|
|
<P>
|
|
|
|
Rewind stdin before reading; needed because the `cat' has already read to the
|
|
end of stdin.
|
|
<BR>
|
|
|
|
<I>% sh -c "cat > plain_copy; xxd -s 0 > hex_copy" < file</I>
|
|
<P>
|
|
|
|
Hexdump from file position 0x480 (=1024+128) onwards.
|
|
The `+' sign means "relative to the current position", thus the `128' adds to
|
|
the 1k where dd left off.
|
|
<BR>
|
|
|
|
<I>% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +128 > hex_snippet" < file</I>
|
|
<P>
|
|
|
|
Hexdump from file position 0x100 ( = 1024-768) on.
|
|
<BR>
|
|
|
|
<I>% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +-768 > hex_snippet" < file</I>
|
|
<P>
|
|
|
|
However, this is a rare situation and the use of `+' is rarely needed.
|
|
The author prefers to monitor the effect of xxd with <A HREF="/cgi-bin/man/man2html?1+strace">strace</A>(1) or <A HREF="/cgi-bin/man/man2html?1+truss">truss</A>(1), whenever -s is used.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>EXAMPLES</H2>
|
|
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Print everything but the first three lines (hex 0x30 bytes) of
|
|
<B>file</B>.
|
|
|
|
<BR>
|
|
|
|
<I>% xxd -s 0x30 file</I>
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Print 3 lines (hex 0x30 bytes) from the end of
|
|
<B>file</B>.
|
|
|
|
<BR>
|
|
|
|
<I>% xxd -s -0x30 file</I>
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Print 120 bytes as continuous hexdump with 20 octets per line.
|
|
<BR>
|
|
|
|
<I>% xxd -l 120 -ps -c 20 xxd.1</I>
|
|
<BR>
|
|
|
|
2e54482058584420312022417567757374203139
|
|
<BR>
|
|
|
|
39362220224d616e75616c207061676520666f72
|
|
<BR>
|
|
|
|
20787864220a2e5c220a2e5c222032317374204d
|
|
<BR>
|
|
|
|
617920313939360a2e5c22204d616e2070616765
|
|
<BR>
|
|
|
|
20617574686f723a0a2e5c2220202020546f6e79
|
|
<BR>
|
|
|
|
204e7567656e74203c746f6e79407363746e7567
|
|
<BR>
|
|
|
|
<P>
|
|
<BR>
|
|
|
|
Hexdump the first 120 bytes of this man page with 12 octets per line.
|
|
<BR>
|
|
|
|
<I>% xxd -l 120 -c 12 xxd.1</I>
|
|
<BR>
|
|
|
|
0000000: 2e54 4820 5858 4420 3120 2241 .TH XXD 1 "A
|
|
<BR>
|
|
|
|
000000c: 7567 7573 7420 3139 3936 2220 ugust 1996"
|
|
<BR>
|
|
|
|
0000018: 224d 616e 7561 6c20 7061 6765 "Manual page
|
|
<BR>
|
|
|
|
0000024: 2066 6f72 2078 7864 220a 2e5c for xxd"..\
|
|
<BR>
|
|
|
|
0000030: 220a 2e5c 2220 3231 7374 204d "..\" 21st M
|
|
<BR>
|
|
|
|
000003c: 6179 2031 3939 360a 2e5c 2220 ay 1996..\"
|
|
<BR>
|
|
|
|
0000048: 4d61 6e20 7061 6765 2061 7574 Man page aut
|
|
<BR>
|
|
|
|
0000054: 686f 723a 0a2e 5c22 2020 2020 hor:..\"
|
|
<BR>
|
|
|
|
0000060: 546f 6e79 204e 7567 656e 7420 Tony Nugent
|
|
<BR>
|
|
|
|
000006c: 3c74 6f6e 7940 7363 746e 7567 <<A HREF="mailto:tony@sctnug">tony@sctnug</A>
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Display just the date from the file xxd.1
|
|
<BR>
|
|
|
|
<I>% xxd -s 0x36 -l 13 -c 13 xxd.1</I>
|
|
<BR>
|
|
|
|
0000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Copy
|
|
<B>input_file</B>
|
|
|
|
to
|
|
<B>output_file</B>
|
|
|
|
and prepend 100 bytes of value 0x00.
|
|
<BR>
|
|
|
|
<I>% xxd input_file | xxd -r -s 100 > output_file</I>
|
|
<BR>
|
|
|
|
<P>
|
|
<BR>
|
|
|
|
Patch the date in the file xxd.1
|
|
<BR>
|
|
|
|
<I>% echo "0000037: 3574 68" | xxd -r - xxd.1</I>
|
|
<BR>
|
|
|
|
<I>% xxd -s 0x36 -l 13 -c 13 xxd.1</I>
|
|
<BR>
|
|
|
|
0000036: 3235 7468 204d 6179 2031 3939 36 25th May 1996
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Create a 65537 byte file with all bytes 0x00,
|
|
except for the last one which is 'A' (hex 0x41).
|
|
<BR>
|
|
|
|
<I>% echo "010000: 41" | xxd -r > file</I>
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Hexdump this file with autoskip.
|
|
<BR>
|
|
|
|
<I>% xxd -a -c 12 file</I>
|
|
<BR>
|
|
|
|
0000000: 0000 0000 0000 0000 0000 0000 ............
|
|
<BR>
|
|
|
|
*
|
|
<BR>
|
|
|
|
000fffc: 0000 0000 40 ....A
|
|
<P>
|
|
|
|
Create a 1 byte file containing a single 'A' character.
|
|
The number after '-r -s' adds to the linenumbers found in the file;
|
|
in effect, the leading bytes are suppressed.
|
|
<BR>
|
|
|
|
<I>% echo "010000: 41" | xxd -r -s -0x10000 > file</I>
|
|
<P>
|
|
|
|
Use xxd as a filter within an editor such as
|
|
<B><A HREF="/cgi-bin/man/man2html?1+vim">vim</A>(1)</B>
|
|
|
|
to hexdump a region marked between `a' and `z'.
|
|
<BR>
|
|
|
|
<I>:'a,'z!xxd</I>
|
|
<P>
|
|
|
|
Use xxd as a filter within an editor such as
|
|
<B><A HREF="/cgi-bin/man/man2html?1+vim">vim</A>(1)</B>
|
|
|
|
to recover a binary hexdump marked between `a' and `z'.
|
|
<BR>
|
|
|
|
<I>:'a,'z!xxd -r</I>
|
|
<P>
|
|
|
|
Use xxd as a filter within an editor such as
|
|
<B><A HREF="/cgi-bin/man/man2html?1+vim">vim</A>(1)</B>
|
|
|
|
to recover one line of a hexdump. Move the cursor over the line and type:
|
|
<BR>
|
|
|
|
<I>!!xxd -r</I>
|
|
<P>
|
|
|
|
Read single characters from a serial line
|
|
<BR>
|
|
|
|
<I>% xxd -c1 < /dev/term/b &</I>
|
|
<BR>
|
|
|
|
<I>% stty < /dev/term/b -echo -opost -isig -icanon min 1</I>
|
|
<BR>
|
|
|
|
<I>% echo -n foo > /dev/term/b</I>
|
|
<P>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>RETURN VALUES</H2>
|
|
|
|
The following error values are returned:
|
|
<DL COMPACT>
|
|
<DT id="18">0<DD>
|
|
no errors encountered.
|
|
<DT id="19">-1<DD>
|
|
operation not supported (
|
|
<I>xxd -r -i</I>
|
|
|
|
still impossible).
|
|
<DT id="20">1<DD>
|
|
error while parsing options.
|
|
<DT id="21">2<DD>
|
|
problems with input file.
|
|
<DT id="22">3<DD>
|
|
problems with output file.
|
|
<DT id="23">4,5<DD>
|
|
desired seek position is unreachable.
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<A HREF="/cgi-bin/man/man2html?1+uuencode">uuencode</A>(1), <A HREF="/cgi-bin/man/man2html?1+uudecode">uudecode</A>(1), <A HREF="/cgi-bin/man/man2html?1+patch">patch</A>(1)
|
|
<BR>
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>WARNINGS</H2>
|
|
|
|
The tools weirdness matches its creators brain.
|
|
Use entirely at your own risk. Copy files. Trace it. Become a wizard.
|
|
<BR>
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>VERSION</H2>
|
|
|
|
This manual page documents xxd version 1.7
|
|
<A NAME="lbAL"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
<BR>
|
|
|
|
(c) 1990-1997 by Juergen Weigert
|
|
<BR>
|
|
|
|
<<A HREF="mailto:jnweiger@informatik.uni-erlangen.de">jnweiger@informatik.uni-erlangen.de</A>>
|
|
<P>
|
|
|
|
Distribute freely and credit me,
|
|
<BR>
|
|
|
|
make money and share with me,
|
|
<BR>
|
|
|
|
lose money and don't ask me.
|
|
<P>
|
|
|
|
Manual page started by Tony Nugent
|
|
<BR>
|
|
|
|
<<A HREF="mailto:tony@sctnugen.ppp.gu.edu.au">tony@sctnugen.ppp.gu.edu.au</A>> <<A HREF="mailto:T.Nugent@sct.gu.edu.au">T.Nugent@sct.gu.edu.au</A>>
|
|
<BR>
|
|
|
|
Small changes by Bram Moolenaar.
|
|
Edited by Juergen Weigert.
|
|
<P>
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="24"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="25"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="26"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="27"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="28"><A HREF="#lbAF">CAVEATS</A><DD>
|
|
<DT id="29"><A HREF="#lbAG">EXAMPLES</A><DD>
|
|
<DT id="30"><A HREF="#lbAH">RETURN VALUES</A><DD>
|
|
<DT id="31"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="32"><A HREF="#lbAJ">WARNINGS</A><DD>
|
|
<DT id="33"><A HREF="#lbAK">VERSION</A><DD>
|
|
<DT id="34"><A HREF="#lbAL">AUTHOR</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:31 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|