hexdump,hd,vi,这三个显示同一文件时字节内容各不相同?

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

hexdump,hd,vi,这三个显示同一文件时字节内容各不相同?

#1

帖子 科学之子 » 2014-05-08 20:30

hexdump,hd,vi,这三个显示同一文件时字节内容各不相同?
左边是:hexdump test|less, 中键是:hd test |less ,右边是:vi test.
注:vi用的是:%!xxd命令
hex查看.png
(8.15 KiB) 已下载 3 次
头像
astolia
论坛版主
帖子: 6703
注册时间: 2008-09-18 13:11

Re: hexdump,hd,vi,这三个显示同一文件时字节内容各不相同?

#2

帖子 astolia » 2014-05-08 20:45

一样的啊

代码: 全选

man hexdump
If no format strings are specified, the default display is equivalent to
specifying the -x option.
-x Two-byte hexadecimal display. Display the input offset in hexa‐
decimal, followed by eight, space separated, four column, zero-
filled, two-byte quantities
of input data, in hexadecimal, per
line.
-C Canonical hex+ASCII display. Display the input offset in hexa‐
decimal, followed by sixteen space-separated, two column, hexa‐
decimal bytes, followed by the same sixteen bytes in %_p format
enclosed in ``|'' characters.

Calling the command hd implies this option.
vi会保证文件以空行结尾,所以后面加了个换行
头像
astolia
论坛版主
帖子: 6703
注册时间: 2008-09-18 13:11

Re: hexdump,hd,vi,这三个显示同一文件时字节内容各不相同?

#3

帖子 astolia » 2014-05-08 21:01

hexdump和hd的默认显示风格就等同于
od -t x2 和 od -t x1

这两个本来就是同一个东西

代码: 全选

$ ls -l /usr/bin/hd 
lrwxrwxrwx 1 root root 7 Jun  4  2013 /usr/bin/hd -> hexdump
回复