Linux 通讯命令

Linux Comm Command

我确定这是一个简单的问题,但我就是不明白...

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

输出:

            abc
 def
            ghi
      klm

为什么第一列显示'def'?我感到困惑的是 "lines unique" 短语。那是什么意思?我在重复的意义上考虑更多,所以我认为所有 3 个单词都会从第 1 列和第 2 列的 file1 和 file2 中显示

Line unique in file 1表示文件1中存在但文件2中不存在的行。 第一列显示 def 因为它对 file1 是唯一的并且在 line2

中不存在

https://en.wikipedia.org/wiki/Comm

阅读更多内容

文件特有的行是出现在该文件中但不出现在其他文件中的行。所以 "def" 出现在第一列是因为它出现在第一个文件中,但没有出现在第二个文件中。