Skip to content

Instantly share code, notes, and snippets.

@knmkr
Last active December 14, 2015 20:09
Show Gist options
  • Select an option

  • Save knmkr/5141954 to your computer and use it in GitHub Desktop.

Select an option

Save knmkr/5141954 to your computer and use it in GitHub Desktop.
md5-check by bash
#!/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