linux日志转储_Linux od命令教程,其中包含转储文件八进制数字格式的示例

linux日志转储

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
Help
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
Display File Octal Mode
Display File Octal Mode
显示文件八进制模式

显示文件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 ASCII Mode
Display File ASCII Mode
显示文件ASCII模式

显示文件小数模式(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
Display File Decimal Mode
Display File Decimal Mode
显示文件小数模式

显示文件十六进制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
Display File Hexadecimal 2 Byte Units
Display File Hexadecimal 2 Byte Units
显示文件十六进制2字节单位

显示文件八进制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 File Octal 2 Byte Units
Display File Octal 2 Byte Units
显示文件八进制2字节单位

显示字节偏移十六进制(Display Byte Offset Hexadecimal)

We can display byte offsets by using -Ax option.

我们可以使用-Ax选项显示字节偏移量。

$ od -Ax test
Display Byte Offset Hexadecimal
Display Byte Offset Hexadecimal
显示字节偏移十六进制

显示字节偏移八进制(Display Byte Offset Octal)

We can display byte offsets by using -Ao option.

我们可以使用-Ao选项显示字节偏移量。

$ od -Ao test
Display Byte Offset Octal
Display Byte Offset Octal
显示字节偏移八进制

显示字节偏移量十进制(Display Byte Offset Decimal)

We can display byte offsets by using -Ad option.

我们可以使用-Ad选项显示字节偏移。

$ od -Ad test
Display Byte Offset Decimal
Display Byte Offset Decimal
显示字节偏移量十进制

隐藏字节偏移(Hide Byte Offset)

While displaying file data we can hide offset information with -An option

在显示文件数据时,我们可以使用-An选项隐藏偏移量信息

$ od -An test
Hide Byte Offset
Hide Byte Offset
隐藏字节偏移

从指定的字节开始显示(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
Start Displaying From Specified Byte
Start Displaying From Specified Byte
从指定的字节开始显示

以指定字节结束显示(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
End Displaying At Specified Byte
End Displaying At Specified Byte
以指定字节结束显示

十六进制指定显示字节的开始和长度(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
Hexadecimal Specify Start and Length Of Displayed Bytes
Hexadecimal Specify Start and Length Of Displayed Bytes
十六进制指定显示字节的开始和长度

从命令行读取输入(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 -
Read Input From Command Line
Read Input From Command Line
从命令行读取输入

显示隐藏字符(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
LEARN MORE  How to Lookup OUI (Organizationally Unique Identifier) In Linux?
了解更多如何在Linux中查找OUI(组织唯一标识符)?

翻译自: https://www.poftut.com/linux-od-command-tutorial-examples-dump-files-octal-number-format/

linux日志转储

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值