Recursively Create MD5-Hashes
1. Juli 2011
Keine Kommentare
If you want to compute MD5 hashes for an directory, you can use following script. I added some exclusions needed for my projects.
#!/bin/bash
DIR="$1"
MD5="file.md5"
if [ -z "$DIR" ]; then
DIR="."
fi
rm -f "$DIR/$MD5"
find \
"$DIR" \
-type f \
-not \( \
-path "*.svn*" -o \
-path "*.cache*" -o \
-path "*.settings*" -o \
-path "*.metadata*" -o \
-name ".buildpath" -o \
-name ".buildpath" -o \
-name ".project" -o \
-name "$MD5" \
\) \
-print0 | \
xargs -0 md5sum >> "$DIR/$MD5"
After that you can check the directory against this file.
md5sum -c file.md5
Kategorienbash, programming language