Skip to content

Instantly share code, notes, and snippets.

@Temikus
Created October 21, 2012 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Temikus/3927125 to your computer and use it in GitHub Desktop.
Save Temikus/3927125 to your computer and use it in GitHub Desktop.
Simple comparator script for UNIX-like systems. i.e. works on FreeBSD and Mac.
#!/bin/bash
#Parses 1st and 2nd argument as directory paths and compares MD5 sums recursively
#Usage: ./comparator.sh /mount/directory /other_mount/directory
find "$1" -type f | while read filename; do
name="${filename#$1*}"
sum1="$(md5 -q "$1$name")"
sum2="$(md5 -q "$2$name")"
if [ "${sum1% *}" = "${sum2% *}" ]; then
echo "ok: $1$name"
else
echo "error: $1$name"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment