Last active
August 16, 2016 06:33
-
-
Save piaoger/da7b6973dd145681890e38026e288809 to your computer and use it in GitHub Desktop.
md5 checksum
This file contains hidden or 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
#md5 generation | |
# linux: md5sum file >md5file | |
# mac: md5 -r file >md5file | |
#Md5 comparison | |
# linux: md5sum -c md5file | |
# mac: manual check ? | |
function find_md5sum() { | |
OS=$(uname) | |
# brew install md5sha1sum | |
if [ "Darwin" == "$OS" ]; then | |
echo "md5 -r" | |
elif [ "Linux" == "$OS" ]; then | |
echo "md5sum" | |
else | |
echo "Unsupported os: $OS" | |
exit 1 | |
fi | |
} | |
md5sum=`find_md5sum` | |
#create md5 file | |
#${md5sum} update-modules-update.sh | awk {'print $1'} >digest.md5 | |
NEWVAL=`${md5sum} update-modules-update.sh | awk {'print $1'}` | |
OLDVAL=`cat ./digest.md5` | |
if [ "$NEWVAL" != "$OLDVAL" ] ; then | |
echo "not equal" | |
#do something... | |
else | |
echo "equal" | |
#do something... | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment