Linux view the od command for details

  • 2020-05-14 05:45:20
  • OfStack

od (octal dump) command

The od(octal dump) command, which displays files or streams in hexadecimal, hexadecimal, hexadecimal, and ASCII codes, is useful for accessing or visually inspecting characters (such as newline characters) in files that cannot be displayed directly on the terminal. In addition, you can use the od command to see the location of the empty space in some files with empty Spaces.

1 general usage format:


od [-aBbcDdeFfHhIiLlOosvXx] [-A base] [-j skip] [-N length] [-t type] [[+]offset[.][Bb]] [file ...]

A simplified version:


od [-A  Address into the system ] [-t  Display format ]  The file name 

Among them:

-A (address base) displays address information in the specified base;

-t specifies the format for data display.

- the address base specified by A includes:

o: base 8 (system default) d: base 10 x: base 106 n: does not print displacement values

The main parameters of the display format specified by t are:

c: ASCII character or backslash sequence (e.g. \n) d: signed decimal number f: floating point number o: base 8 (system default) u: unsigned decimal number x: base 106

Example: display the contents of file aa in ASCII code


slot@slot-ubt:~/test$ cat aa
hello
world
slot@slot-ubt:~/test$ 
slot@slot-ubt:~/test$ od -tc aa
0000000 h e l l o \n w o r l d \n
0000014
slot@slot-ubt:~/test$

Display 1 again in base 106, 8 and 10 formats, respectively:


slot@slot-ubt:~/test$ od -tcx aa
0000000 h e l l o \n w o r l d \n
    6c6c6568  6f770a6f  0a646c72
0000014
slot@slot-ubt:~/test$ 
slot@slot-ubt:~/test$ od -tco aa
0000000 h e l l o \n w o r l d \n
   15433062550  15735605157  01231066162
0000014
slot@slot-ubt:~/test$ od -tcd aa
0000000 h e l l o \n w o r l d \n
    1819043176  1870072431  174353522
0000014
slot@slot-ubt:~/test$

The base 106 format for each character in hello world is as follows:


0x680x650x6c0x6c0x6f
0x770x6f0x720x6c0x64

conclusion

The above is the entire content of od command about Linux view command. I hope the content of this article can bring you some help in your study or work. If you have any questions, you can leave a message to communicate.


Related articles: