(go) Use of the OD command under Linux

Source: Internet
Author: User
Tags tmp file

Use of the OD command under Linux

Original: http://blog.csdn.net/shylock_backer/article/details/46473283

Name: OD
Function: Format the data in the output file
Feed:
od [OPTION] ... [FILE] ...
od [-abcdfilosx] ... [FILE] [[+]offset[.] [b]]
OD--traditional [OPTION] ... [FILE] [[+]offset[.] [b] [+][label][.] [b]]
Description
Common files are text files and binary files. This command is primarily used to view values that are saved in a binary file. For example, a program may output a large number of data records, each of which is a single-precision floating point. These data records are stored in a file, and the Od command comes in handy if you want to see the data. In my opinion, the OD command is primarily used to format output file data, meaning that the data in the file is interpreted with no ambiguity. The OD command outputs their values as required, regardless of the floating-point or ASCII code in the IEEE754 format.
If no file name is specified, or if the file name is "-", the data is read from the standard input

-A: Specifies the address cardinality, and the output of the OD command is offset from the leftmost 1 column. The default offset is 8 binary and can be modified using-a.
The format is:-a parameter. The parameters you can use are: D: Decimal, O: octal, x: hexadecimal; n does not display offset column.

-j: The number of bytes skipped when the file is opened.
The format is:-j BYTES. Bytes is a numeric value, starting with 0 for 8, with the beginning of the 0x is 16 binary, with B as the suffix of 1 bytes, with K as the suffix of 1024 bytes, denoted by M as the suffix 1,048,576 bytes.

-N: Number of bytes used to limit output
The format is:-N BYTES. The bytes format is the same as above.

-S: Specifies how many graphic characters the output string occupies
The format is:-S BYTES.

-T: Select the output format.
The format is:-T [Acdfoux][size].
A: the name corresponding to each ASCII code.
B: ASCII code value corresponding to the character in octal byte
D: Signed value, size byte
F: Floating-point number, size byte
O: Octal number, size byte
U: Unsigned value, size byte
X: Hexadecimal number, size byte
Note: The size here is either a numeric value or a letter. The range of letters is: [CSILFD]. For non-F types, the general choice is csil. where c denotes sizeof (char), s denotes sizeof (short), I denotes sizeof (int), and L represents sizeof (long). If type f,sizeof can be f or D, Represents sizeof (float) or sizeof (double), respectively.
You can use the traditional format:
-A: Equivalent to-t a. A name that represents an ASCII code
-B: Equivalent to-t O1, select single byte and interpret by octal number of 3 numeric digits
-C: Equivalent to-t C, select ASCII character or escape character
-D: Equivalent to-t u2: Select unsigned 2-byte units
-F: Equivalent to-t FF, select single-precision floating-point number
-I: Equivalent to-t DI, select Decimal integer
-L: Equivalent to-t DL, select Decimal Long Integer
-O: Equivalent to-t O2, select two-byte units and interpret according to octal
-S: equivalent to-t D2, select two byte units and interpret in decimal
-X: Equivalent to-t x2, select two byte units and make hex interpretation

-V: Do not replace duplicate output

-W: Sets the width of each row, that is, the number of bytes to be output on each line
Format:-W BYTES

Examples are as follows:
Description: Prepare a TMP file first
[[email protected] ~]$ echo abcdef g > tmp
[email protected] ~]$ cat tmp
ABCdef g


Description: Use a single-byte octal interpretation for output, noting that the default address format on the left is eight bytes
[Email protected] ~]$ od-b tmp
0000000 141 142 143 144 145 146 040 147 012
0000011


Description: Use ASCII code for output, note that includes escape characters
[Email protected] ~]$ od-c tmp
0000000 a b c d e f g \ n
0000011


Description: Use single-byte decimal for interpretation
[Email protected] ~]$ od-t d1 tmp
0000000 97 98 99 100 101 102 32 103 10
0000011


Description: Set the address format to decimal
[Email protected] ~]$ od-a d-c tmp
0000000 a b c d e f g \ n
0000009


Description: Set the address format to hexadecimal
[Email protected] ~]$ od-a x-c tmp
000000 a b c d e f g \ n
000009


Description: Skips the start of the two bytes
[Email protected] ~]$ OD-J 2-c tmp
0000002 C d E f g \ n
0000011


Description: Skips the start of two bytes and outputs only two bytes
[Email protected] ~]$ od-n 2-j 2-c tmp
0000002 C D
0000004


Description: Output only 1 bytes per line
[Email protected] ~]$ od-w1-c tmp
0000000 A
0000001 b
0000002 C
0000003 D
0000004 E
0000005 F
0000006
0000007 g
0000010 \ n
0000011


Description: Output of two bytes per line
[Email protected] ~]$ od-w2-c tmp
0000000 a B
0000002 C D
0000004 E F
0000006 g
0000010 \ n
0000011


Description: Outputs 3 bytes per line and is interpreted using octal single byte
[Email protected] ~]$ od-w3-b tmp
0000000 141 142 143
0000003 144 145 146
0000006 040 147 012
0000011

(go) Use of the OD command under Linux

Related Article

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.