加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux hexdump使用

发布时间:2020-12-14 00:23:18 所属栏目:Linux 来源:网络整理
导读:# hexdump -hhexdump: invalid option -- ‘h‘Usage: hexdump [options] file...Options: -b one-byte octal display#单字节八进制显示 -c one-byte character display#单字节字符显示 -C canonical hex+ASCII display#规范化 十六进制+ASCII 显示 -d two-b
# hexdump -h
hexdump: invalid option -- ‘h‘

Usage:
 hexdump [options] file...

Options:
 -b              one-byte octal display#单字节八进制显示
 -c              one-byte character display#单字节字符显示
 -C              canonical hex+ASCII display#规范化 十六进制+ASCII 显示
 -d              two-byte decimal display#两字节十进制显示
 -o              two-byte octal display#两字节八进制显示
 -x              two-byte hexadecimal display#两字节十六进制显示
 -e format       format string to be used for displaying data#格式 用于显示数据的格式字符串
 -f format_file  file that contains format strings#格式文件 包含格式字符串的文件
 -n length       interpret only length bytes of input#长度 只解释输入的指定长度个字节
 -s offset       skip offset bytes from the beginning#偏移 跳过开头指定长度个字节
 -v              display without squeezing similar lines#显示时不压缩相似的行
 -V              output version information and exit#显示此帮助并退出

  

# more a.txt 
abcde
ABCDE
# hexdump a.txt 
0000000 6261 6463 0a65 4241 4443 0a45          
000000c

  

第一列表示:文件偏移量
第二列表示:以两个字节为一组的十六进制
上面的输出结果翻译一下,就是:

badc0aeBADC0aE

(注意:在Linux中换行符n 的十六进制为0a,在windows中,换行为rn的十六进制编码为:0d 0a)

为什么翻译成文本成倒序了呢?

其实这是CPU架构所致,感兴趣的可以看下大小端的定义:
1) Little-Endian就是低位字节排放在内存的低地址端,高位字节排放在内存的高地址端。(X86 CPU系列采用的位序)
2) Big-Endian就是高位字节排放在内存的低地址端,低位字节排放在内存的高地址端。
3) 网络字节序:TCP/IP各层协议将字节序定义为Big-Endian,因此TCP/IP协议中使用的字节序通常称之为网络字节序。

有没有更加较便于方便的查看方式了?有,这也是较常用的方式。
以16进制和相应的ASCII字符显示文件里的字符:

# hexdump -C a.txt 
00000000  61 62 63 64 65 0a 41 42  43 44 45 0a              |abcde.ABCDE.|
0000000c

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读