linux-xxd

xxdLinux平台下的一款工具,可以用于原文件二进制文件之间的互相转换。
man page描述:

1
2
3
4
5
xxd  creates a hex dump of a given file or standard input.  It can also
convert a hex dump back to its original binary form. Like uuencode(1)
and uudecode(1) it allows the transmission of binary data in a `mail-
safe' ASCII representation, but has the advantage of decoding to stan‐
dard output. Moreover, it can be used to perform binary file patching

  • xxd常用方法
1
2
3
4
5
6
7
8
9
10
➜  ~ echo 'hello,world' > origin.txt

# 将文件内容转换为十六进制内容
➜ ~ xxd origin.txt
00000000: 6865 6c6c 6f2c 776f 726c 640a hello,world.

# 将十六进制内容恢复到一个新文件中
➜ ~ xxd origin.txt |xxd -r > new.text
➜ ~ cat new.text
hello,world

xxd还支持将文件转换成二进制,格式化输出等。具体可查看官方文档


参考:
1.linux-man-page-xxd