Skip to content

Instantly share code, notes, and snippets.

@zouzias
Created July 7, 2015 08:02
Show Gist options
  • Save zouzias/9ceff2b666edd32707e1 to your computer and use it in GitHub Desktop.
Save zouzias/9ceff2b666edd32707e1 to your computer and use it in GitHub Desktop.
MD5: Check md5 of all files from a directory
#!/bin/bash
# Check md5 from all files in a dir. It assumes that for each file "filename.txt" there exists a "filename.txt.md5" corresponding file
FILES=`ls *`
for f in $FILES
do
# echo "Processing $f"
MD5=`md5 $f`
TRUE_MD5=`cat $f.md5`
if [ "$MD5" == "$TRUE_MD5" ];
then
echo "File $f : OK";
else
echo "MD5 is NOT valid on file $f"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment