Last active
August 20, 2019 13:34
-
-
Save beporter/fb21306900952ba8a742 to your computer and use it in GitHub Desktop.
Compare a known md5 hash against that of a downloaded file.
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
#!/user/bin/env bash | |
# $1 = file to digest | |
# $2 = expected hash | |
# Exits zero if the hashes match, outputs the difference if they do not and exits non-zero. | |
diff \ | |
<(md5 ${1?"Provide a valid file path as the first argument."} | cut -f 4 -d ' ' -) \ | |
<(echo ${2?"Provide the expected md5 hash as the second argument."}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment