Created
July 7, 2014 14:34
-
-
Save kyon0304/665e7ab08a44c37b8102 to your computer and use it in GitHub Desktop.
最近总是在作的重复性工作,比较两个二进制文件的内容是否一致。。Orz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
s1=`du -b $1|cut -f1` | |
s2=`du -b $2|cut -f1` | |
min=$(($s1 < $s2 ? $s1 : $s2 )) | |
if [ $min -eq $s1 ]; then | |
dd if=$2 of=temp bs=$min count=1 >& /dev/null | |
echo $1 is smaller and its md5sum is: | |
echo $(md5sum $1) | |
echo cut $2 to $1\'s size and its md5sum is: | |
else | |
dd if=$1 of=temp bs=$min count=1 >& /dev/null | |
echo $2 is smaller and its md5sum is: | |
echo $(md5sum $2) | |
echo cut $1 to $2\'s size and its md5sum is: | |
fi | |
echo $(md5sum temp) | |
rm temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment