Created
November 6, 2015 03:03
-
-
Save mreschke/c9fbb9985755cfb068ea to your computer and use it in GitHub Desktop.
Compare md5sums of all files between two directories
This file contains 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 | |
#Compare md5sums of all files between two directories | |
#mReschke 2012-06-14 | |
src=$1 | |
dest=$2 | |
if [ "$src" != "" -a "$dest" != "" ]; then | |
if [ -e "$src" -a -e "$dest" ]; then | |
rand=$[ ( $RANDOM % 99999999 ) + 1 ] | |
sums=/tmp/md5compare_${rand}_md5checksums | |
results=/tmp/md5compare_${rand}_results | |
echo -e "\033[0;32mComparing $src and $dest md5sums\033[0;0m" | |
(cd "$src" && find . -type f -exec md5sum {} \;) | (cd "$dest" && md5sum -c -) | tee -a $results | |
#(cd "$src" && find . -type f -exec md5sum {} \;) | (cd "$dest" && md5sum -c -) \ | |
#| awk '{ if (substr($2, length($2)-2,2) == "OK") { | |
# printf("%s", $1) | |
#} else { | |
# printf("\r\n\033[0;31m%s %s\033[0;0m\r\n", "FAILED:",$1) | |
#} | |
#}' | |
#rand=$[ ( $RANDOM % 99999999 ) + 1 ] | |
#sums=/tmp/md5compare_${rand}_md5checksums | |
#results=/tmp/md5compare_${rand}_results | |
#cd $src | |
#find . -type f -exec md5sum {} \; | tee -a $sums | |
#cd $dest | |
#md5sum -c $sums | tee $results | |
echo | |
echo "Greping for errors, you should see nothing here" | |
/bin/grep --color=auto FAILED $results | |
echo | |
echo "Done. Results file can be found here $results" | |
else | |
echo "Either the source or the destination directory does not exist" | |
fi | |
else | |
echo "Enter a source and destination directory" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment