我想查看当前目录中文件的内容,但从命令行以二进制格式查看。我怎样才能做到这一点呢?


当前回答

如果你想打开二进制文件(在CentOS 7中):

strings <binary_filename>

其他回答

XXD处理二进制和十六进制。

bin:

xxd -b file

hex:

xxd file
$ echo -n 'Hello world!' | hd
00000000  48 65 6c 6c 6f 20 77 6f  72 6c 64 21              |Hello world!|
0000000c

以十六进制形式在一行中获得所有输出:

xxd -p yourfile.bin | tr -d '\n'

您可以打开emacs(在终端模式下,例如使用emacs -nw),然后使用Hexl模式:M-x Hexl -mode。

https://www.gnu.org/software/emacs/manual/html_node/emacs/Editing-Binary-Files.html

己基格式很好:sudo apt安装己基