Skip to content

Instantly share code, notes, and snippets.

@kyon0304
Created July 7, 2014 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyon0304/665e7ab08a44c37b8102 to your computer and use it in GitHub Desktop.
Save kyon0304/665e7ab08a44c37b8102 to your computer and use it in GitHub Desktop.
最近总是在作的重复性工作,比较两个二进制文件的内容是否一致。。Orz
#!/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