bash 如何从bash查看二进制文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1765311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to view files in binary from bash?
提问by adam_0
I would like to view the contents of a file in the current directory, but in binary from the command line. How can I achieve this?
我想查看当前目录中文件的内容,但是从命令行查看二进制文件。我怎样才能做到这一点?
回答by Emilio Bool
回答by tyranid
hexdump -C yourfile.bin
unless you want to edit it of course. Most linux distros have hexdump
by default (but obviously not all).
除非你当然想编辑它。大多数 linux 发行版hexdump
默认都有(但显然不是全部)。
回答by Duck
vi your_filename
hit esc
打 esc
Type :%!xxd
to view the hex strings, the n :%!xxd -r
to return to normal editing.
键入:%!xxd
查看十六进制字符串,在n:%!xxd -r
恢复到正常的编辑。
回答by Jim Garrison
As a fallback there's always od -xc filename
作为后备,总是有 od -xc filename
回答by Raju
If you want to open binary files (in CentOS 7):
如果你想打开二进制文件(在 CentOS 7 中):
strings <binary_filename>
回答by siddiq
sudo apt-get install bless
sudo apt-get install bless
Bless is GUI tool which can view, edit, seach and a lot more. Its very light weight.
Bless 是一个 GUI 工具,可以查看、编辑、搜索等等。它的重量很轻。
回答by Aalex Gabi
$ echo -n 'Hello world!' | hd
00000000 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 |Hello world!|
0000000c
回答by intgr
回答by dividebyzero
You can open emacs (in terminal mode, using emacs -nw
for instance), and then use Hexl mode: M-x hexl-mode
.
您可以打开 emacs(在终端模式下,emacs -nw
例如使用),然后使用 Hexl 模式:M-x hexl-mode
。
https://www.gnu.org/software/emacs/manual/html_node/emacs/Editing-Binary-Files.html
https://www.gnu.org/software/emacs/manual/html_node/emacs/Editing-Binary-Files.html
回答by craken
You can use hexdump binary file
您可以使用 hexdump 二进制文件
sudo apt-get install hexdump
hexdump -C yourfile.bin