Created
October 13, 2011 13:25
-
-
Save jonathanpenn/1284207 to your computer and use it in GitHub Desktop.
A directory diff'ing script written using Unix magic piping files through `md5` to compare their contents.
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 | |
# In honor of Dennis Ritchie, I present my directory diff'ing | |
# script built on the piping magic of Unix. | |
# | |
# Usage: diffdir dir1 dir2 | |
set -e # Bomb out of the script on any errors | |
diff_directories() { | |
stream1=<(generate_manifest "$1") | |
stream2=<(generate_manifest "$2") | |
diff $stream1 $stream2 || echo "" | |
} | |
generate_manifest() { | |
echo "manifest for $1" | |
(cd "$1" && (find . -type f -exec /sbin/md5 {} \; | sort)) | |
} | |
diff_directories "$1" "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment