I have two files and I want to see if the first 40 bytes are similar. How can I do this using hex dump?
我有两个文件,我想看看前40个字节是否相似。我怎么能用hex dump做到这一点?
3 个解决方案
#1
5
If you are using the BSD hexdump
utility (which will also be installed as hd
, with a different default output format) then you can supply the -n40
command line parameter to limit the dump to the first 40 bytes:
如果您正在使用BSD hexdump实用程序(它也将安装为hd,具有不同的默认输出格式),那么您可以提供-n40命令行参数以将转储限制为前40个字节:
hexdump -n40 filename
If you are using the Posix standard od
, you need a capital N
. You might find the following invocation useful:
如果您使用Posix标准od,则需要大写N.您可能会发现以下调用很有用:
od -N40 -w40 -tx1 -Ax filename
(You can do that with hexdump
, too, but the format string is more work to figure out :) ).
(您也可以使用hexdump来实现,但格式字符串更多的工作要弄清楚:))。
#2
1
Try this:
head -c 40 myfile | hexdump
#3
0
Not sure why you need hexdump here,
不知道为什么你需要hexdump,
diff <(dd bs=1 count=40 if=file1) <(dd bs=1 count=40 if=file2)
with hexdump:
diff <(dd bs=1 count=40 if=file1|hexdump) <(dd bs=1 count=40 if=file2|hexdump)
#1
5
If you are using the BSD hexdump
utility (which will also be installed as hd
, with a different default output format) then you can supply the -n40
command line parameter to limit the dump to the first 40 bytes:
如果您正在使用BSD hexdump实用程序(它也将安装为hd,具有不同的默认输出格式),那么您可以提供-n40命令行参数以将转储限制为前40个字节:
hexdump -n40 filename
If you are using the Posix standard od
, you need a capital N
. You might find the following invocation useful:
如果您使用Posix标准od,则需要大写N.您可能会发现以下调用很有用:
od -N40 -w40 -tx1 -Ax filename
(You can do that with hexdump
, too, but the format string is more work to figure out :) ).
(您也可以使用hexdump来实现,但格式字符串更多的工作要弄清楚:))。
#2
1
Try this:
head -c 40 myfile | hexdump
#3
0
Not sure why you need hexdump here,
不知道为什么你需要hexdump,
diff <(dd bs=1 count=40 if=file1) <(dd bs=1 count=40 if=file2)
with hexdump:
diff <(dd bs=1 count=40 if=file1|hexdump) <(dd bs=1 count=40 if=file2|hexdump)