commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
This is a modified version of the OP, wrapped into a bash function.
This version handles newlines and other whitespace correctly, the original has problems with the thankfully rare case of newlines in the file names.
It also allows checking an arbitrary number of directories against each other, which is nice when the directories that you think might have duplicates don't have a convenient common ancestor directory.