Linux directive: OD
Example usage: od-c Hello
Linux directive: OD
OD command
Users typically use the OD command to view file content in a special format. You can display files in decimal, octal, hexadecimal, and ASCII codes by specifying different options for the command.
Syntax: OD [options] File ...
Meaning of the options in the command:
-A Specifies the address base, including:
D Decimal
o Octal (System default)
X hex
n Do not print displacement values
-t specifies the display format of the data, the main parameters are:
C ASCII character or backslash sequence
D Signed Decimal number
F Floating point number
o Octal (system default is 02)
U unsigned decimal number
x hexadecimal number
In addition to option C, you can follow a decimal number n to specify the number of bytes that each display value contains.
Description: The OD command system is displayed by default in octal, which is also the name of the command (octal
Dump). But this is not the most useful way to display, the combination of ASCII and hexadecimal can provide more valuable information output.
For example:
- $ od-ax-tcx1 wh5
- 000000 F i l e s y S t e m
- 6c 65 73 79 73 6d 20
- 000010 1 k-b l o C k s
- (6b) 2d + 6c 6f 6b 20
- 000020 U S e d a v a i l A b
- All-in-all 6c 62
- 000030 l e u s e% M o u n T e d
- 6c 4d 6f 74 6e 65 64 20
-
- ----My Test-----
- [email protected]:~ ; CA T a
- hello,world.
- joey.
- [Email protected]:~>
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 inspecting characters in a file that cannot be displayed directly on the terminal.
Here documentation
There is a special redirect worth mentioning in this tutorial. While strictly speaking, here documentation is a shell like bash
, not anything related to the text utility, but they provide a useful way to send special data to a text utility.
Double less than sign redirection can be used to receive the contents of a pseudo-file from a terminal. The here document must be immediately followed by a terminating delimiter in <<.
Such as:
- <<end
- >
- >
- >
Any string can be used as a delimiter, and the input terminates where the string itself is encountered on a single line. This gives us a quick way to create a persistent file:
- <<eof
- >
- >
- >
Linux OD command