Unix command to find lines common in two files


I'm sure I once found a Unix command which could print the common lines from two or more files. What is its name?

It was much simpler than diff.

Best Solution

The command you are seeking is comm. eg:-

comm -12 1.sorted.txt 2.sorted.txt


-1 : suppress column 1 (lines unique to 1.sorted.txt)

-2 : suppress column 2 (lines unique to 2.sorted.txt)