Detailed introduction to Linux Command od

Source: Internet
Author: User

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:

 
 
  1. $ od - Ax - tcx1 wh5  
  2. 000000 F i l e s y s t e m  
  3. 46 69 6c 65 73 79 73 74 65 6d 20 20 20 20 20 20  
  4. 000010 1 k - b l o c k s  
  5. 20 20 20 20 20 31 6b 2d 62 6c 6f 63 6b 73 20 20  
  6. 000020 U s e d A v a i l a b  
  7. 20 20 20 20 55 73 65 64 20 41 76 61 69 6c 61 62  
  8. 000030 l e U s e % M o u n t e d  
  9. 6c 65 20 55 73 65 25 20 4d 6f 75 6e 74 65 64 20  
  10.  
  11. ---- My test -----  
  12. ysun@linetcps1dev:~> cat a  
  13. hello,world.  
  14. Joey.  
 
 
  1. ysun@linetcps1dev:~> od -Ax -tcx4 a  
  2. 000000 h e l l o , w o r l d . \n \t J o  
  3. 6c6c6568 6f772c6f 2e646c72 6f4a090a  
  4. 000010 e y . \n \n \0 \0 \0  
  5. 0a2e7965 0000000a  
  6. 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:

 
 
  1. $ od -c <<END 
  2. > Alice  
  3. > Bob  
  4. > END  
  5. 0000000 A l i c e \n B o b \n  
  6. 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:

 
 
  1. $ cat myfile <<EOF 
  2. > Dave  
  3. > Edna  
  4. > EOF  
  5. $ hexdump -C myfile  
  6. 00000000 44 61 76 65 0a 45 64 6e 61 0a |Dave.Edna.|  
  7. 0000000a 

This is the knowledge of Linux Command od.

  1. Easily connect to the campus network using Linux
  2. Fully Understand Linux Process Technology
  3. Introduction to the password command in Linux
  4. Learn about Linux regulatory commands
  5. How to view the ps-aux command of all processes in Linux

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.