判断二进制文件是否相同
时间:2008-05-03 来源:剑心通明
下面的脚本简略判断二进制文件是否相同,只采样一次,要修改采样位置大小,只能修改脚本。
#!/bin/bash
#email:[email protected]
#msn:[email protected]
#oicq:28995895
#hexdump -x -n 16 -s 100
n=16 ##采样大小
s=200 ##采样位置
if [ ! $# = 2 ];then
echo usage: $0 hexfile1 hexfile2
exit 0
fi
hex1=`hexdump -x -n $n -s $s $1`
hex2=`hexdump -x -n $n -s $s $2`
if [ "$hex1" != "$hex2" ];then
echo different files
fi
下面的脚本比较两个二进制文件
#!/bin/bash
#email:[email protected]
#msn:[email protected]
#oicq:28995895
#hexdump -x -n 16 -s 100
if [ ! $# = 2 ];then
echo usage: $0 hexfile1 hexfile2
exit 0
fi
hexdump -x $1>/tmp/hexdiff_001.tmp
hexdump -x $2>/tmp/hexdiff_002.tmp
diff /tmp/hexdiff_001.tmp /tmp/hexdiff_002.tmp
#!/bin/bash
#email:[email protected]
#msn:[email protected]
#oicq:28995895
#hexdump -x -n 16 -s 100
n=16 ##采样大小
s=200 ##采样位置
if [ ! $# = 2 ];then
echo usage: $0 hexfile1 hexfile2
exit 0
fi
hex1=`hexdump -x -n $n -s $s $1`
hex2=`hexdump -x -n $n -s $s $2`
if [ "$hex1" != "$hex2" ];then
echo different files
fi
下面的脚本比较两个二进制文件
#!/bin/bash
#email:[email protected]
#msn:[email protected]
#oicq:28995895
#hexdump -x -n 16 -s 100
if [ ! $# = 2 ];then
echo usage: $0 hexfile1 hexfile2
exit 0
fi
hexdump -x $1>/tmp/hexdiff_001.tmp
hexdump -x $2>/tmp/hexdiff_002.tmp
diff /tmp/hexdiff_001.tmp /tmp/hexdiff_002.tmp
相关阅读 更多 +