With the rapid development of computers, many people begin to learn about Linux and learn how to learn Linux commands well. To learn about Linux, you may have knowledge about the Linux Command od. Here we will introduce the Linux Command od application method.
Linux Command: od
Example: od-c hello
Linux Command: od
Od command
Users usually use the od command to view the content of files in special formats. You can specify different options for this command to display files in decimal, octal, hexadecimal, and ASCII code.
Syntax: od [Option] file...
Meaning of each option in the command:
-A specifies the address base, including:
D decimal
O octal system default value)
X hexadecimal
N do not print the displacement value
-T specifies the data display format. The main parameters include:
C ASCII character or backslash Sequence
D. Signed decimal number
F floating point number
O octal System Default Value: 02)
U unsigned decimal number
X hexadecimal number
Other options except option c can be followed by a decimal number n, specifying the number of bytes contained in each display value.
Note: The default display mode of the od command system is Octal, which is also the origin of the command name Octal.
Dump ). However, this is not the most useful display method. The combination of ASCII code and hexadecimal code can provide more valuable information output.
For example:
- $ od - Ax - tcx1 wh5
- 000000 F i l e s y s t e m
- 46 69 6c 65 73 79 73 74 65 6d 20 20 20 20 20 20
- 000010 1 k - b l o c k s
- 20 20 20 20 20 31 6b 2d 62 6c 6f 63 6b 73 20 20
- 000020 U s e d A v a i l a b
- 20 20 20 20 55 73 65 64 20 41 76 61 69 6c 61 62
- 000030 l e U s e % M o u n t e d
- 6c 65 20 55 73 65 25 20 4d 6f 75 6e 74 65 64 20
-
- ---- My test -----
- ysun@linetcps1dev:~> cat a
- hello,world.
- Joey.
- ysun@linetcps1dev:~> od -Ax -tcx4 a
- 000000 h e l l o , w o r l d . \n \t J o
- 6c6c6568 6f772c6f 2e646c72 6f4a090a
- 000010 e y . \n \n \0 \0 \0
- 0a2e7965 0000000a
- 000015
Od and hexdump
The utility od and hexdump output the octal, hexadecimal, or other encoded bytes of the file or stream respectively. They are useful for accessing or visually checking characters in files that cannot be directly displayed on the terminal.
HERE document
There is a special redirection that is worth mentioning in this tutorial. Strictly speaking, the HERE document is a shell such as bash.
But they provide a useful way to send special data to a text utility.
Dual-sign redirection can be used to receive the contents of pseudo files from the terminal. The HERE document must follow <to specify a termination separator.
For example:
- $ od -c <<END
- > Alice
- > Bob
- > END
- 0000000 A l i c e \n B o b \n
- 0000012
Any string can be used as a separator. The input terminates where the string itself is encountered on a line. This provides a quick way to create a persistent file:
- $ cat myfile <<EOF
- > Dave
- > Edna
- > EOF
- $ hexdump -C myfile
- 00000000 44 61 76 65 0a 45 64 6e 61 0a |Dave.Edna.|
- 0000000a
This is the knowledge of Linux Command od.
- Easily connect to the campus network using Linux
- Fully Understand Linux Process Technology
- Introduction to the password command in Linux
- Learn about Linux regulatory commands
- How to view the ps-aux command of all processes in Linux