LINUX

LINUX OD指令

介紹

od指令用八進位來檢視檔案。

語法

od [options] [files]

常用的options

-N B            Display only the first B bytes of each file, specified in decimal, hexadecimal (by prepending 0x or 0X), 512-byte blocks (by appending b), kilobytes (by appending k), or megabytes (by appending m). (Default displays the entire file)

-j B            Begin the output at byte B+1 of each file; acceptable formats are the same as for the -N option. (Default=0)

-w[B]           Display B bytes per line; acceptable formats are the same as in the -N option. Using -w by itself is equivalent to -w32. (Default=16)

-s[B]           Group each row of bytes into sequences of B bytes, separated by whitespace; acceptable formats are the same as in -N option. Using -s by itself is equivalent to -s3. (Default=2)

-A (d|o|x|n)    Display file offsets in the leftmost column, in decimal(d), octal(o), hexadecimal(x), or not at all(n). (Default=o)

-t(a|c)[z]      Display output in a character format, with nonalphanumeric characters printed as escape sequences(c) or by name(a).

-t(d|o|u|x)[z]  Display output in an integer format, including octal(o), signed decimal(d), unsigned decimal(u), hexadecimal(x).

Appending z to the -t option prints a new column on the righthand side of the output, displaying the printable characters on each line.

範例

你可以用八進位來檢視檔案,最左邊的那一行為偏移位址(Offset):

⤍ od /usr/bin/who
0000000 042577 043114 000402 000001 000000 000000 000000 000000
0000020 000003 000076 000001 000000 024040 000000 000000 000000
0000040 000100 000000 000000 000000 152000 000000 000000 000000

每一行顯示8 bytes:

⤍ od -w8 /usr/bin/who
0000000 042577 043114 000402 000001
0000010 000000 000000 000000 000000
0000020 000003 000076 000001 000000

如果檔案內包含字串,可以使用-t

⤍ od -tc /usr/bin/who
0000000 177   E   L   F 002 001 001  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000020 003  \0   >  \0 001  \0  \0  \0       (  \0  \0  \0  \0  \0  \0
0000040   @  \0  \0  \0  \0  \0  \0  \0  \0 324  \0  \0  \0  \0  \0  \0

發佈留言