Skip to content

Instantly share code, notes, and snippets.

@jonathanpenn
Created October 13, 2011 13:25
Show Gist options
  • Save jonathanpenn/1284207 to your computer and use it in GitHub Desktop.
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.
#!/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