Created
May 26, 2020 13:14
-
-
Save jperocho/a81a2ac793cba2ed4d770de7ede3ac18 to your computer and use it in GitHub Desktop.
Check sha256 hash value
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 | |
FILE=$1 | |
HASH=$2 | |
[ -z "$FILE" ] && echo "Please provide valid file" | |
if [ -f "$FILE" ]; then | |
FILESUM=$(shasum -a 256 $FILE | cut -f 1 -d ' ' | grep '[a-f0-9]') | |
if [ -z "$HASH" ]; then | |
echo $FILESUM | |
else | |
[[ $FILESUM == $HASH ]] && echo "Ok" || echo "Not Ok" | |
fi | |
else | |
echo "$FILE does not exist, Please provide valid file" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment