Today, I went to send a weekly email to a list I maintain in Contacts, and I noticed that my group had inexplicably lost 7 cards! So I restored the contact cards from Time machine, which allowed me to only "Keep New" ones. However, I ended up with more cards than I knew I was supposed to have.
So I tried using Contacts' "Look for Duplicates" feature, but it would not let me review the duplicates. It simply told me that I had 28 duplicate cards and 8 duplicate entries based on people having the same name, and offered to let me either select Merge or Cancel. I'd sorted out messy merges before, so I wasn't about to get into that morass. So I devised my own way of finding and reviewing duplicates.
First, I selected my group, clicked the name at the top, then Shift-clicked the last name to highlight all the cards. I then dragged them into the to field of an empty email. I then typed Command-A to select them again and pasted them into a temporary TextEdit plain text document which I named "dupe_search.txt". (If anyone knows a way to skip the email/drag step, let me know.) I then ran the text document through this set of piped commands in Terminal:
This returns a list of email addresses with the number of times they occur in Contacts to the left. I then manually searched for each one in Contacts to inspect the dupes.
cut -f 2 -d '<' dupe_search.txt | cut -f 1 -d '>' | sort | uniq -c | grep -v " 1 "
Mac OS X Hints