Linux od command
The Linux od command is used to output file contents.
The od command reads the contents of the given file and presents them as octal byte codes.
Syntax
od [-abcdfhilovx][-A <字码基数>][-j <字符数目>][-N <字符数目>][-s <字符串字符数>][-t <输出格式>][-w <每列字符数>][--help][--version][文件...]
Parameters:
- -a This option has the same effect as specifying the "-ta" parameter.
- -A
Choose the base to use for number codes. - -b This option has the same effect as specifying the "-toC" parameter.
- -c This option has the same effect as specifying the "-tC" parameter.
- -d This option has the same effect as specifying the "-tu2" parameter.
- -f This option has the same effect as specifying the "-tfF" parameter.
- -h This option has the same effect as specifying the "-tx2" parameter.
- -i This option has the same effect as specifying the "-td2" parameter.
- -j
or --skip-bytes= Skip the set number of characters. - -l This option has the same effect as specifying the "-td4" parameter.
- -N
or --read-bytes= Up to the set number of characters. - -o This option has the same effect as specifying the "-to2" parameter.
- -s
or --strings= Display only strings that match the specified number of characters. - -t
or --format= Set the output format. - -v or --output-duplicates Do not omit duplicate data when outputting.
- -w
or --width= Set the maximum number of characters per column. - -x This option has the same effect as specifying the "-h" parameter.
- --help Online help.
- --version Display version information.
Example
Create a tmp file:
$ echo abcdef g > tmp
$ cat tmp
abcdef g
Use the od command:
$ od -b tmp
0000000 141 142 143 144 145 146 040 147 012
0000011
Output using single-byte octal interpretation. Note that the default address format on the left is eight bytes:
$ od -c tmp
0000000 a b c d e f g \n
0000011
Output using ASCII codes, noting that escape characters are included
$ od -t d1 tmp
0000000 97 98 99 100 101 102 32 103 10
0000011
Interpret using single-byte decimal
$ od -A d -c tmp
0000000 a b c d e f g \n
0000009
Linux Command Reference