Display lines common in two files

 

comm – command is to to compare two sorted files line by line.

By default (without no options) it will produce 3 colums as output.

  • Column 1 contains lines unique to file1.
  • Column 2 contains lines unique to file2.
  • Column 3 contains lines common to both files.

Example:

$ comm file1 file2

$ comm -1 file1 file2

$ comm -2 file1 file2

$ comm -3 file1 file2

In above examples

-1 is for surpass lines unique to file1.

-2 is for surpass lines unique to file2.

-3 is for surpass lines that appear in both files.

-Sany

Leave a comment