Last active
December 14, 2015 20:09
-
-
Save knmkr/5141954 to your computer and use it in GitHub Desktop.
md5-check by bash
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 | |
| # USAGE: md5check [files] | |
| # | |
| # example: ./md5check *.gz | |
| if [ $# -eq 0 ]; then | |
| echo "USAGE: md5check [files]" | |
| exit 0 | |
| fi | |
| for file in "$@"; do | |
| if [ ! -f ${file}.md5 ]; then | |
| echo "-------------------------------------" | |
| echo "[WARNING] ${file}.md5 does not exists" | |
| echo "-------------------------------------" | |
| else | |
| generated_md5=`md5 -q "$file"` | |
| answer_md5=`cut -d' ' -f2 "$file".md5` | |
| if [ $generated_md5 != $answer_md5 ]; then | |
| echo "-------------------------------------" | |
| echo "[WARNING] md5 for ${file} does not match" | |
| echo "-------------------------------------" | |
| fi | |
| echo "${file} ...ok" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment