Linux-Xxd from Man Manual (MARK)

Source: Internet
Author: User
Tags array definition rewind stdin

XXD (1) General Commands Manual XXD (1)



NAME
Xxd-make a hexdump or do the reverse.

Synopsis
XXD-H[ELP]
xxd [Options] [infile [outfile]]
Xxd-r[evert] [options] [infile [outfile]]

DESCRIPTION
XXD 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 uuen‐
Code (1) and UUDecode (1) It allows the transmission of binary data in a ' mail-safe ' ASCII representation, but have the the Advan Tage of decoding
to standard output. Moreover, it can be used to perform binary file patching.

OPTIONS
If no infile is given, standard input is read.  If infile is specified as a '-' character and then input was taken from standard input. If No
OutFile is given (or a '-' character was in it place), results was sent to standard output.

Note that a "lazy" parser are used which does not check for more than the first option letter, unless the option is Followe D by a parameter.
Spaces between a single option, and its parameter is optional. Parameters to options can is specified in decimal, hexadecimal or
Octal notation. THUS-C8,-C 8,-C 010 and-cols 8 is all equivalent.


-B | -bits
Switch to bits (binary digits) dump, rather than hexdump. This option writes octets as eight digits "1" s and "0" s instead of a nor‐
Mal hexadecimal dump. Each of the line are 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. #以二进制模式显示, default is 16, option-r,-p,-I cannot be paired with this option

-r | -revert
Reverse Operation:convert (or patch) hexdump into binary. If not writing to stdout, Xxd writes into its output file without trun‐
Cating it. Use the Combination-r-p to read plain hexadecimal dumps without line number information and without a particular column
Layout. Additional whitespace and Line-breaks are allowed anywhere.

#转换为二进制显示


-P | -ps | -postscript | -plain
Output in PostScript continuous hexdump style. Also known as plain hexdump style.

#连续显示字符, no blank.

-I. | -include
Output in C include the file style. A complete static array definition was written (named after the input file), unless Xxd reads from
Stdin.

****************************************************************************************************

-C cols | -cols cols
Format <cols> octets per line. Default (-i:12,-ps:30,-b:6). Max 256.

#一行显示多少个列或者字符, default of 16 characters

-S [+][-]seek
Start at <seek> bytes abs. (or rel.) infile offset. + indicates that the seek was relative to the current stdin file position (mean‐
Ingless when not reading from stdin). -Indicates that the seek should is that many characters from the end of the the input (or if com‐
Bined with +: Before the current stdin file position). Without-s option, Xxd starts at the current file position.

+0x30 0x30 discards the first 3 lines, starting with the 0X30 + 1 characters, which is the fourth line

-0X30 0x30 Show only the last three rows

The default 16-character hexadecimal representation of a line is 0x10, so 3 lines are 0x30

-L Len | -len Len
Stop after writing <len> octets.

#总共显示多少个字符


-seek Offset
When used After-r: revert with <offset> added to file positions found in Hexdump.


-A | -autoskip
Toggle autoskip:a Single ' * ' Replaces nul-lines. Default off.

#nul-lines with a * alternative. Default off


-U use upper case hex letters.      Default is lower case. #用大写表示字母


-E | -ebcdic
The character encoding in the righthand column from ASCII to EBCDIC. This does the hexadecimal representation. The
option is meaningless in combinations with-r,-P or-i.

-G Bytes | -groupsize bytes
Separate the output of every <bytes> bytes (both hex characters or eight bit-digits each) by a whitespace. Specify-g 0 to suppress
Grouping.  <Bytes> defaults to 2 in normal mode and 1 in bits mode. Grouping does not an apply to PostScript or include style.


-H | -help
Print a summary of available commands and exit. No hex dumping is performed.


-V | -version
Show version string.

Caveats
Xxd-r have some builtin magic while evaluating line number information. If the output file is seekable and then the linenumbers at the start
of each hexdump line is out of order, lines is missing, or overlapping.  In these cases xxd would lseek (2) to the next position. If
The output file is not a seekable, only gaps is allowed, which would be filled by null-bytes.

Xxd-r never generates parse errors. Garbage is silently skipped.

When editing hexdumps, please note this xxd-r skips everything on the input line after reading enough columns of hex Adecimal data (see
OPTION-C). This also means, which changes to the printable ASCII (or EBCDIC) columns is always ignored. Reverting a plain (or PostScript)
Style hexdump with Xxd-r-p does not depend on the correct number of columns. Here anything this looks like a pair of hex-digits is inter‐
Preted.

Note the difference between
% Xxd-i File
and
% Xxd-i < file

Xxd-s +seek May was different from xxd-s seek, as Lseek (2) was 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!) ...

Rewind stdin before reading; needed because the ' cat ' has already read to the end of stdin.
% sh-c "Cat > Plain_copy; Xxd-s 0 > hex_copy "< file

Hexdump from file position 0x480 (=1024+128) onwards. The ' + ' sign means "relative-to-the-position", thus the ' adds to the 1k
where DD left off.
% sh-c "dd Of=plain_snippet bs=1k count=1; Xxd-s +128 > Hex_snippet "< file

Hexdump from the file position 0x100 (= 1024-768) on.
% sh-c "dd Of=plain_snippet bs=1k count=1; Xxd-s +-768 > Hex_snippet "< file

However, this was a rare situation and the use of ' + ' is rarely needed. The author prefers to monitor the effect of XXD with Strace (1) or
Truss (1), whenever-s is used.

EXAMPLES
Print Everything but the first three lines (hex 0x30 bytes) of file.
% xxd-s 0x30 file

Print 3 lines (hex 0x30 bytes) from the end of file.
% xxd-s -0x30 file

Print bytes as continuous hexdump with + octets per line.
% xxd-l 120-ps-c Xxd.1
2e54482058584420312022417567757374203139
39362220224d616e75616c207061676520666f72
20787864220a2e5c220a2e5c222032317374204d
617920313939360a2e5c22204d616e2070616765
20617574686f723a0a2e5c2220202020546f6e79
204e7567656e74203c746f6e79407363746e7567

Hexdump the first bytes of this mans page with a octets per line.
% xxd-l 120-c Xxd.1
0000000:2e54 4820 5858 4420 3120 2241. TH XXD 1 "A
000000c:7567 7573 7420 3139 3936 2220 ugust 1996 "
0000018:224d 616e 7561 6c20 7061 6765 "Manual page
0000024:2066 6f72 2078 7864 220a 2e5c for Xxd ". \
0000030:220a 2e5c 2220 3231 7374 204d ". \ "21st M
000003c:6179 2031 3939 360a 2e5c 2220 ay 1996..\ "
0000048:4d61 6e20 7061 6765 2061 7574 man page aut
0000054:686f 723a 0a2e 5c22 2020 2020 Hor:.. \"
0000060:546f 6e79 204e 7567 656e 7420 Tony Nugent
000006c:3c74 6f6e 7940 7363 746e 7567 <tony@sctnug

Display just the date from the file Xxd.1
% xxd-s 0x36-l 13-c Xxd.1
0000036:3231 7374 204d 6179 2031 3939 21st 1996

Copy input_file to Output_file and prepend bytes of value 0x00.
% Xxd Input_file | Xxd-r-S > Output_file

Patch the date in the file Xxd.1
% echo "0000037:3,574 68" | Xxd-r-Xxd.1
% xxd-s 0x36-l 13-c Xxd.1
0000036:3235 7468 204d 6179 2031 3939 25th 1996

Create a 65537 byte file with all bytes 0x00, except for the last one which is ' a ' (hex 0x41).
% echo "010000:41" | Xxd-r > File

Hexdump this file with Autoskip.
% XXD-A-C-File
0000000:0000 0000 0000 0000 0000 0000 ......
*
000fffc:0000 0000 40 .... A

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 is suppressed.
% echo "010000:41" | Xxd-r-s-0x10000 > file

Use Xxd as a filter within an editor such as VIM (1) to hexdump a region marked between ' a ' and ' Z '.
: ' A, ' z!xxd

Use Xxd as a filter within an editor such as VIM (1) to recover a binary hexdump marked between ' a ' and ' Z '.
: ' A, ' z!xxd-r

Use Xxd as a filter within an editor such as VIM (1) To recover one line of a hexdump. Move the cursor over the line and type:
!! Xxd-r

Read single characters from a serial line
% Xxd-c1 </dev/term/b &
% Stty </dev/term/b-echo-opost-isig-icanon min 1
% echo-n Foo >/dev/term/b

RETURN VALUES
The following error values are returned:

0 No errors encountered.

-1 Operation not supported (Xxd-r-I still impossible).

1 Error while parsing options.

2 problems with input file.

3 problems with output file.

4,5 desired seek position is unreachable.

See ALSO
Uuencode (1), UUDecode (1), Patch (1)

WARNINGS
The tools weirdness matches its creators brain. Use entirely at your own risk. Copy files. Trace it. Become a wizard.

VERSION
This manual page documents XXD version 1.7

AUTHOR
(c) 1990-1997 by Juergen Weigert
<jnweiger@informatik.uni-erlangen.de>

Distribute freely and credit me,
Make money and share with me,
Lose money and don ' t ask me.

Manual page started by Tony Nugent
<tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au>
Small changes by Bram Moolenaar. Edited by Juergen Weigert.

Manual page for Xxd August 1996 XXD (1)

Linux-Xxd from Man Manual (MARK)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.