Possible Duplicate:
how to show lines in common (reverse diff)?
Is there a command to do the opposite of diff? I want to compare two files if the same thing exists in both create a list of them. i am trying to figure out what entry's exist in both files.
Use the join command:
join a.txt b.txt
assuming the files are sorted; if not:
Here is a solution that WILL NOT change the order of the lines: