Created
September 6, 2015 21:13
-
-
Save kostasdizas/189e91aca22cd24abb2c to your computer and use it in GitHub Desktop.
Quickly calculate a checksum for a file and compare with input
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 | |
# compare calculated from file and input checksums for any hash function | |
if [ $# -lt 3 ] ; then | |
echo 'usage -- comparechecksum hashfunction filename checksum' | |
exit 1 | |
fi | |
[ $($1 $2 | cut -f 1 -d " ") == $3 ] && echo "OK: All good" || echo "NOT OK: File does not match given checksum" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment