Skip to content

Instantly share code, notes, and snippets.

@rewida17
Created February 1, 2018 15:01
Show Gist options
  • Save rewida17/7c6381475e9515e49173c8656b1b304e to your computer and use it in GitHub Desktop.
Save rewida17/7c6381475e9515e49173c8656b1b304e to your computer and use it in GitHub Desktop.
MD5 compare files #BASH #AWK #MD5
#!/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