Gnu comm

From wikinotes

comm lets you operate on differences between two files.
ex.

  • only lines that appear in file1
  • only lines that appear in file2
  • only lines that appear in both file1 and file2

Usage

comm -1 file1.txt file2.txt  # only lines unique to first file
comm -2 file1.txt file2.txt  # only lines unique to second file
comm -3 file1.txt file2.txt  # only lines shared by both first/second file