Created
February 1, 2018 15:01
-
-
Save rewida17/7c6381475e9515e49173c8656b1b304e to your computer and use it in GitHub Desktop.
MD5 compare files #BASH #AWK #MD5
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
#!/bin/bash | |
#This part of script is responsible of checking the file | |
test(){ | |
f1="$(md5sum "$1" | awk '{print $1}')" | |
f2="$(md5sum "$2" | awk '{print $1}')" | |
if [ "$f1" == "$f2" ] | |
then | |
printf "\\nFiles is correct\\nSUM1: %s $f1\\nSUM2: $f2\\n\\n" | |
else | |
printf "\\nFiles is not correct!!!:\\nSUM1:%s $f1\\nSUM2: %s$f2\\n\\n" | |
fi | |
} | |
usage(){ | |
printf "\\nThis script use 'md5sum' to check files\\nUsage:\\f%s$(basename "$0") File1 File2\\n\\n" | |
} | |
## Maybe needed help? ;) If don`t test files :) | |
if [ "$1" == "-h" ] || [ "$1" == "--help" ] | |
then | |
usage | |
else | |
test "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment