Linux Command xxd

Source: Internet
Author: User
Tags 0xc0

 

The command xxd is useful when we need to convert the binary into a hexadecimal character array used in the C language.

Xxd help information is as follows: key options are marked as black.

[Root @ localhost] # xxd -- Help
Usage:
Xxd [Options] [infile [OUTFILE]
Or
Xxd-R [-s [-] offset] [-C Cols] [-PS] [infile [OUTFILE]
Options:
-A toggle autoskip: A single '*' replaces NUL-lines. Default off.
-B binary digit dump (incompatible with-P,-I,-R). Default hex.
-C Cols format <Cols> octets per line. Default 16 (-I: 12,-PS: 30 ).
-E show characters in ebcdic. Default ASCII.
-G Number of ETS per group in normal output. Default 2. The number of bytes for each goup. The default value is 2, which can be set.
-H print this summary.
-I output in C include file Style.: The output is the style of C containing files. The array method exists.
-L Len stop after <Len> octets.: after converting to Len, the conversion stops.
-PS output in postscript plain hexdump style.
-R reverse operation: Convert (or patch) hexdump into binary.
-R-s off revert with <off> added to file positions found in hexdump.
-S [+] [-] seek start at <seek> bytes abs. (or +: REL.) infile offset.
-U use upper case hex letters.: bytes are capitalized.
-V show version: "xxd v1.10 27oct98 by Juergen Weigert ".

For example:

> Xxd-G 1-I-u-l 10000000 nm. TS> xxd_test.txt

Generated text display:

Unsigned char _ 0513_1634_ch32_666_10_ts [] = {
0x47, 0x02, 0x03, 0x13, 0xf8, 0x5a, 0xc5, 0x40, 0x26, 0xe4, 0xd0, 0xde,
0xad, 0xb8, 0x76, 0x89, 0x85, 0x23, 0x06, 0x04, 0x6e, 0x05, 0x8b, 0x09,
0xc0, 0x5c, 0x96, 0x4f, 0x18, 0x51, 0x41, 0xc8, 0x40, 0x9f, 0x06, 0x93,
0x38, 0xc1, 0xbb, 0x1a, 0xbc, 0xac, 0x47, 0xff, 0x5e, 0x54, 0xeb, 0xa7,
0x14, 0x36, 0x85, 0x8a, 0x90, 0x14, 0x17, 0xa2, 0x9d, 0xc0, 0x84, 0x56,
0xcb, 0x97, 0x78, 0xc8, 0x57, 0x15, 0x3e, 0x61, 0x6f, 0xfe, 0xc9, 0x39,
0xef, 0xd3, 0xb6, 0x6a, 0xd2, 0xe4, 0xfb, 0x4c, 0x05, 0xf6, 0x03, 0xed,
0x50, 0xb3, 0xe7, 0x46, 0x57, 0x24, 0x71, 0x16, 0x38, 0x45, 0x53, 0x19,
0x56, 0x25, 0x3c, 0x8d, 0x4c, 0xa9, 0x28, 0x9a, 0xb2, 0x99, 0x76, 0x52,
0x28, 0xe9, 0xd6, 0xd6, 0x11, 0x94, 0x89, 0x19, 0x4d, 0xea, 0x68, 0x76,
0x53, 0xc6, 0xaa, 0x3a, 0xd4, 0xa1, 0x25, 0xa5, 0x03, 0xb0, 0x73, 0xa0,
0xae, 0x11, 0xc9, 0xbd, 0x37, 0x17, 0x11, 0x5f, 0x30, 0x34, 0x34, 0x0b

.....

};

Unsigned int nm. ts_len = 10000000;

In addition, in Vim, you can also convert the file to a hexadecimal format to display:

: %! Xxd

Normal display is returned:

: %! Xxd-R

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.