Do you know about `comm`? Given two sorted files it will show you in three columns.
* unique lines to file1
* unique lines to file2
* lines common to both files
You can pass it various options to suppress any of the three columns.I once had an interview at Facebook where one of the problems was easily solved by `comm`. I found it funny that the interviewer, or anyone who reviewed the interview question, had never heard of it. I was a good sport about it though, I ended up writing a janky Perl script that roughly implemented `comm` to solve the problem, which (modulo Perl) was what they wanted me to do.