Linux系统自带16进制查看器:hd和hexdump,使用方法如下:
-> # cat test.c
#include<stdio.h>
int main(void){
printf("hello world");
reutrn 0;
}
-> # hexdump test.c
0000000 6923 636e 756c 6564 733c 6474 6f69 682e
0000010 0a3e 6e69 2074 616d 6e69 7628 696f 2964
0000020 0a7b 7009 6972 746e 2866 6822 6c65 6f6c
0000030 7720 726f 646c 2922 0a3b 7209 7565 7274
0000040 206e 3b30 7d0a 000a
0000047
-> # hd test.c
00000000 23 69 6e 63 6c 75 64 65 3c 73 74 64 69 6f 2e 68 |#include<stdio.h|
00000010 3e 0a 69 6e 74 20 6d 61 69 6e 28 76 6f 69 64 29 |>.int main(void)|
00000020 7b 0a 09 70 72 69 6e 74 66 28 22 68 65 6c 6c 6f |{..printf("hello|
00000030 20 77 6f 72 6c 64 22 29 3b 0a 09 72 65 75 74 72 | world");..reutr|
00000040 6e 20 30 3b 0a 7d 0a |n 0;.}.|
00000047
hd相当于在右边多了转换成字符的显示。
hd
其实是link到hexdump
的,执行的命令相当于hexdump -C
:
-> # ls -l `which hd`
lrwxrwxrwx 1 root root 7 Apr 12 2017 /usr/bin/hd -> hexdump
hexdump
应该是在所有的Linux系统上都有安装的:Debian,Ubuntu,centos,arch等
除了hexdump,另外一个常用的十六进制阅读器是xxd
:
-> # xxd test.c
00000000: 2369 6e63 6c75 6465 3c73 7464 696f 2e68 #include<stdio.h
00000010: 3e0a 696e 7420 6d61 696e 2876 6f69 6429 >.int main(void)
00000020: 7b0a 0970 7269 6e74 6628 2268 656c 6c6f {..printf("hello
00000030: 2077 6f72 6c64 2229 3b0a 0972 6575 7472 world");..reutr
00000040: 6e20 303b 0a7d 0a n 0;.}.