hexdump
用于查看二进制和其他进制文本和非文本文件内容
[01:55:25 root@C8-3-55 ~]#hexdump --help
用法:
hexdump [选项] <文件>...
以十六进制、十进制、八进制、二进制或 ascii 显示文件内容。
选项:
-b, --one-byte-octal 单字节八进制显示
-c, --one-byte-char 单字节字符显示
-C, --canonical 规范化 hex+ASCII 显示
-d, --two-bytes-decimal 双字节十进制显示
-o, --two-bytes-octal 双字节八进制显示
-x, --two-bytes-hex 双字节十六进制显示
-L, --color[=<模式>] 解释颜色格式化限定符
默认启用颜色
-e, --format <格式> 用于显示数据的格式化字符串
-f, --format-file <文件> 包含格式字符串的文件
-n, --length <长度> 只解释规定字节长度的输入
-s, --skip <偏移> 跳过开头的指定字节偏移
-v, --no-squeezing 输出相同的行
-h, --help display this help
-V, --version display version
更多信息请参阅 hexdump(1)。
- 显示二十六个字母对应的二进制数
[02:03:29 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | hexdump -C ##显示{a..z}|删除空格|以规范化ascii显示
00000000 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 |abcdefghijklmnop|
00000010 71 72 73 74 75 76 77 78 79 7a 0a |qrstuvwxyz.|
0000001b
od
[02:05:30 root@C8-3-55 ~]#od --help
用法:od [选项]... [文件]...
或:od [-abcdfilosx]... [文件] [[+]偏移量[.][b]]
或:od --traditional [选项]... [文件] [[+]偏移量[.][b] [+][标签][.][b]]
Write an unambiguous representation, octal bytes by default,
of FILE to standard output. With more than one FILE argument,
concatenate them in the listed order to form the input.
如果没有指定文件,或者文件为"-",则从标准输入读取。
If first and second call formats both apply, the second format is assumed
if the last operand begins with + or (if there are 2 operands) a digit.
An OFFSET operand means -j OFFSET. LABEL is the pseudo-address
at first byte printed, incremented when dump is progressing.
For OFFSET and LABEL, a 0x or 0X prefix indicates hexadecimal;
suffixes may be . for octal and b for multiply by 512.
必选参数对长短选项同时适用。
-A, --address-radix=RADIX output format for file offsets; RADIX is one
of [doxn], for Decimal, Octal, Hex or None
--endian={big|little} swap input bytes according the specified order
-j, --skip-bytes=BYTES skip BYTES input bytes first
-N, --read-bytes=BYTES limit dump to BYTES input bytes
-S BYTES, --strings[=BYTES] output strings of at least BYTES graphic chars;
3 is implied when BYTES is not specified
-t, --format=TYPE select output format or formats
-v, --output-duplicates do not use * to mark line suppression
-w[BYTES], --width[=BYTES] output BYTES bytes per output line;
32 is implied when BYTES is not specified
--traditional accept arguments in third form above
--help 显示此帮助信息并退出
--version 显示版本信息并退出
Traditional format specifications may be intermixed; they accumulate:
-a same as -t a, select named characters, ignoring high-order bit
-b same as -t o1, select octal bytes
-c same as -t c, select printable characters or backslash escapes
-d same as -t u2, select unsigned decimal 2-byte units
-f 即 -t fF,指定浮点数对照输出格式
-i 即 -t dl,指定十进制整数对照输出格式
-l 即 -t dL,指定十进制长整数对照输出格式
-o 即 -t o2,指定双字节单位八进制数的对照输出格式
-s 即 -t d2,指定双字节单位十进制数的对照输出格式
-x 即 -t x2,指定双字节单位十六进制数的对照输出格式
TYPE is made up of one or more of these specifications:
a named character, ignoring high-order bit
c printable character or backslash escape
d[SIZE] signed decimal, SIZE bytes per integer
f[SIZE] floating point, SIZE bytes per float
o[SIZE] octal, SIZE bytes per integer
u[SIZE] unsigned decimal, SIZE bytes per integer
x[SIZE] hexadecimal, SIZE bytes per integer
SIZE is a number. For TYPE in [doux], SIZE may also be C for
sizeof(char), S for sizeof(short), I for sizeof(int) or L for
sizeof(long). If TYPE is f, SIZE may also be F for sizeof(float), D
for sizeof(double) or L for sizeof(long double).
Adding a z suffix to any type displays printable characters at the end of
each output line.
BYTES is hex with 0x or 0X prefix, and may have a multiplier suffix:
b 512
KB 1000
K 1024
MB 1000*1000
M 1024*1024
and so on for G, T, P, E, Z, Y.
[02:06:26 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | od -t x
0000000 64636261 68676665 6c6b6a69 706f6e6d
0000020 74737271 78777675 000a7a79
0000033
[02:07:09 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | od -x
0000000 6261 6463 6665 6867 6a69 6c6b 6e6d 706f
0000020 7271 7473 7675 7877 7a79 000a
0000033
[02:09:38 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | od -t x1
0000000 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70
0000020 71 72 73 74 75 76 77 78 79 7a 0a
0000033
[02:09:44 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | od -t x2
0000000 6261 6463 6665 6867 6a69 6c6b 6e6d 706f
0000020 7271 7473 7675 7877 7a79 000a
0000033
[02:09:47 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | od -t x1z
0000000 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 >abcdefghijklmnop<
0000020 71 72 73 74 75 76 77 78 79 7a 0a >qrstuvwxyz.<
0000033
[02:10:43 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | od -t x2z
0000000 6261 6463 6665 6867 6a69 6c6b 6e6d 706f >abcdefghijklmnop<
0000020 7271 7473 7675 7877 7a79 000a >qrstuvwxyz.<
0000033
xxd
[02:10:48 root@C8-3-55 ~]#xxd --help
Usage:
xxd [options] [infile [outfile]]
or
xxd -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]
Options:
-a toggle autoskip: A single '*' replaces nul-lines. Default off.
-b binary digit dump (incompatible with -ps,-i,-r). Default hex.
-C capitalize variable names in C include file style (-i).
-c cols format <cols> octets per line. Default 16 (-i: 12, -ps: 30).
-E show characters in EBCDIC. Default ASCII.
-e little-endian dump (incompatible with -ps,-i,-r).
-g number of octets per group in normal output. Default 2 (-e: 4).
-h print this summary.
-i output in C include file style.
-l len stop after <len> octets.
-o off add <off> to the displayed file position.
-ps output in postscript plain hexdump style.
-r reverse operation: convert (or patch) hexdump into binary.
-r -s off revert with <off> added to file positions found in hexdump.
-s [+][-]seek start at <seek> bytes abs. (or +: rel.) infile offset.
-u use upper case hex letters.
-v show version: "xxd V1.10 27oct98 by Juergen Weigert".
[02:11:41 root@C8-3-55 ~]#echo {a..z} | tr -d ' ' | xxd
00000000: 6162 6364 6566 6768 696a 6b6c 6d6e 6f70 abcdefghijklmnop
00000010: 7172 7374 7576 7778 797a 0a qrstuvwxyz.