Skip to content

Instantly share code, notes, and snippets.

@flbuddymooreiv
Last active August 29, 2015 14:23
Show Gist options
  • Save flbuddymooreiv/633e5cb97b6febceb702 to your computer and use it in GitHub Desktop.
Save flbuddymooreiv/633e5cb97b6febceb702 to your computer and use it in GitHub Desktop.
Compare one directory tree's contents to another's (structure doesn't matter)
IFS=$'\n'; 
find /path/to/src -type f > sourcefiles
find /path/to/dest -type f > destfiles
for x in $(cat sourcefiles); do md5sum "$x" >> sourcechecksums; done;
for x in $(cat destfiles); do md5sum "$x" >> destfiles; done;

IFS=' '; 
hex="0 1 2 3 4 5 6 7 8 9 a b c d e f"; 
for f in sourcechecksums destchecksums; 
do 
    for x in $hex; do for y in $hex; do for z in $hex; 
    do 
        cat checksums.$f | grep ^$x$y$z | sort > checksums.$f.$x$y$z; 
    done; done; done; 
done;

hex="0 1 2 3 4 5 6 7 8 9 a b c d e f";
for x in $hex; do for y in $hex; do for z in $hex; 
do
    if [ -e sourcechecksums.$x$y$z ];
    then
        while read l; 
            do grep $(echo $l | cut -d ' ' -f 1) destchecksums.$x$y$z > /dev/null;
            if [ $? -ne 0 ];
            then
                echo $l >> missingdata;
            fi;
        done < sourcechecksums.$x$y$z;
    fi;
done; done; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment