命令名称
xxd - 做一次十六进制的输出或者反操作
xxd命令语法
xxd [options] [infile [outfile]]
xxd -r[evert] [options] [infile [outfile]]
xxd命令描述
xxd命令为给定的标准输入或者文件做一次十六进制的输出,它也可以将十六进制输出转换为原来的二进制格式。
xxd命令常用选项
选项 | 描述 |
-b | 用二进制显示一个bit,而不是十六进制 |
-r | 以十六进制作为输入,二进制作为输出 |
-s [+][-]seek | 从<seek>字节开始。+ -分别表示相对于文件的开头和结尾 |
-seek offset | 从offset数值开始显示 |
xxd命令实例
[root@shellcn.net ~#] cat 1.txt
111111111111111
######将1.txt转化为十六进制输出
[root@shellcn.net ~#] xxd 1.txt
0000000: 3131 3131 3131 3131 3131 3131 3131 310a 111111111111111.
######从第五个offset开始显示
[root@shellcn.net ~#] xxd -seek 5 1.txt
0000005: 3131 3131 3131 3131 3131 0a 1111111111.
######使用 -r选项将十六进制输出又返回为二进制输出
[root@shellcn.net ~#] xxd 1.txt |xxd -r
111111111111111