Skip to content

Instantly share code, notes, and snippets.

@kostasdizas
Created September 6, 2015 21:13
Show Gist options
  • Save kostasdizas/189e91aca22cd24abb2c to your computer and use it in GitHub Desktop.
Save kostasdizas/189e91aca22cd24abb2c to your computer and use it in GitHub Desktop.
Quickly calculate a checksum for a file and compare with input
#!/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