In Unix based systems like Linux and Mac OS X there are a number of ways of comparing two directories. The simplest way is to use diff:
diff –brief -rb directory_1 directory_2
This command compares each file and reports if they differ. You can find the meanings of the options in man diff.
Diff is fine if you’re on a fast drive, if there aren’t many files or the files aren’t big. The command compares the contents of each file so it can take quite some time on a slow external drive.
If you just want to know which files are in one directory and not in the other directory it’s overkill. This little bit of Bash scripting does that however:
diff <(cd dir1 && find | sort) <(cd dir2 && find | sort)
It still uses diff, but compares the file listing of each directory instead of the files. It’s much faster and perfect for figuring out what files are out of place on my 2 relatively slow USB drives. (source)