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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s