Skip to content

Instantly share code, notes, and snippets.

@beporter
Last active August 20, 2019 13: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 beporter/fb21306900952ba8a742 to your computer and use it in GitHub Desktop.
Save beporter/fb21306900952ba8a742 to your computer and use it in GitHub Desktop.
Compare a known md5 hash against that of a downloaded file.
#!/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