Search code examples
linuxcomm

Linux Comm Command


I'm sure this is an easy question but I'm just not understanding...

Ex.

  cat file1.txt
  abc
  def
  ghi

  cat file2.txt
  abc
  ghi
  klm

  comm file1.txt file2.txt

  So I know first column displays lines unique in file1
  Second : lines unique in file2
  Third: lines common in both

Output :

            abc
 def
            ghi
      klm

Why does it show 'def' in the first column? What I'm confused about is "lines unique" phrase. What does that mean? I'm thinking more in the sense of duplicates so I was thinking all 3 of the words would displayed from file1 and file2 in columns 1 and 2


Solution

  • Line unique in file 1 means line which exists in file1 but not file 2. First column displays def because it is unique to file1 and does not exist in line2

    Read more at https://en.wikipedia.org/wiki/Comm