linux日志转储
od is a tool used to dump files or input in different presentation formtas like octal, decimal, hexadecimal etc. od command especially useful for binary analysis also can be used to debug Linux scripts for unwanted characters.
od是用于转储文件或以八进制,十进制,十六进制等不同表示形式输入的工具。od命令对二进制分析特别有用,也可用于调试Linux脚本中不需要的字符。
帮帮我 (Help)
$ od --help
句法(Syntax)
od [OPTION]... [FILE]...
显示文件八进制模式 (Display File Octal Mode)
Octal mode is calculated with base 8 . We can print the file contents with -b
option.
八进制模式以8为底进行计算。 我们可以使用-b
选项打印文件内容。
$ od -b test
显示文件ASCII模式(Display File ASCII Mode)
As octal mode do not provide a human readable format. We humans generally uses ASCII or character mode to read. We can print all contents of the file with -c
option.
由于八进制模式不提供人类可读的格式。 我们人类通常使用ASCII或字符模式进行读取。 我们可以使用-c
选项打印文件的所有内容。
$ od -c test
显示文件小数模式(Display File Decimal Mode)
Decimal mode is base 10 for numeric formatting. Humans generally uses decimal mode to made math and numerical operations. We will use -i
option.
十进制模式是数字格式的基数10。 人们通常使用小数模式进行数学和数字运算。 我们将使用-i
选项。
$ od -i test
显示文件十六进制2字节单位(Display File Hexadecimal 2 Byte Units)
While displaying the printed as one byte interpretation. If the chars are Unicode and written as 2 byte displaying them 2 byte is a requirement.
同时显示打印为一字节的解释。 如果字符是Unicode并写为2字节,则要求显示2字节。
$ od -x test
显示文件八进制2字节单位(Display File Octal 2 Byte Units)
We can also display provided file as 2 byte units in octal mode. We will use -o
option.
我们还可以在八进制模式下以2字节为单位显示提供的文件。 我们将使用-o
选项。
$ od -o test
显示字节偏移十六进制(Display Byte Offset Hexadecimal)
We can display byte offsets by using -Ax
option.
我们可以使用-Ax
选项显示字节偏移量。
$ od -Ax test
显示字节偏移八进制(Display Byte Offset Octal)
We can display byte offsets by using -Ao
option.
我们可以使用-Ao
选项显示字节偏移量。
$ od -Ao test
显示字节偏移量十进制(Display Byte Offset Decimal)
We can display byte offsets by using -Ad
option.
我们可以使用-Ad
选项显示字节偏移。
$ od -Ad test
隐藏字节偏移(Hide Byte Offset)
While displaying file data we can hide offset information with -An
option
在显示文件数据时,我们可以使用-An
选项隐藏偏移量信息
$ od -An test
从指定的字节开始显示(Start Displaying From Specified Byte)
While displaying files the files may contain a lot of data. We may looking for some specific part of the file. Here we can specify the start byte index with -j
option.
在显示文件时,文件可能包含很多数据。 我们可能会寻找文件的某些特定部分。 在这里,我们可以使用-j
选项指定起始字节索引。
$ od -j10 -c test
以指定字节结束显示(End Displaying At Specified Byte)
Another option to specify the part we want to display is setting the end index of the file. We will set the end index number with -N
option.
指定我们要显示的部分的另一个选项是设置文件的结束索引。 我们将使用-N
选项设置结束索引号。
$ od -N50 -c test
十六进制指定显示字节的开始和长度(Hexadecimal Specify Start and Length Of Displayed Bytes)
If we merge two previous example we can specify start and length of the byte index with -j
and -N
options.
如果我们合并前面的两个示例,则可以使用-j
和-N
选项指定字节索引的开始和长度。
$ od -j30 -N50 -c test
从命令行读取输入(Read Input From Command Line)
Up to now we have provided related data from a file. ob command can also read data from standard input. We will use -
to specify reading data from standard input. In order to end the read press CTRL+d
到目前为止,我们已经从文件中提供了相关数据。 ob命令还可以从标准输入读取数据。 我们将使用-
指定从标准输入读取数据。 为了结束读取,请按CTRL+d
$ od -c -
显示隐藏字符(Display Hidden Characters)
Some characters do not displayed by regular file commands and tools. But od command can display these hidden characters by default.
常规文件命令和工具无法显示某些字符。 但是od命令默认可以显示这些隐藏字符。
$ od -c test
翻译自: https://www.poftut.com/linux-od-command-tutorial-examples-dump-files-octal-number-format/
linux日志转储