Created
October 30, 2016 23:01
-
-
Save inflation/120998bfa304830421365fa9a894907a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
METHOD='md5' | |
usage() { | |
echo "Usage: cpsm [-m METHOD] filename [CHECKSUM]" | |
exit 1 | |
} | |
[ $# -eq 0 ] && usage | |
while getopts :m: OPTION | |
do | |
case $OPTION in | |
m) | |
METHOD=$OPTARG | |
;; | |
\?) | |
usage | |
;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
if [[ $# -eq 0 ]]; then | |
usage | |
fi | |
CKSM=$(openssl $METHOD $1 | awk '{print $2}') | |
if [[ -z $2 ]]; | |
then | |
echo $CKSM | |
exit 0; | |
fi | |
if [[ $CKSM == $2 ]]; | |
then | |
echo 'Match!' | |
else | |
echo 'Not Match!' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment