English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux-Befehl comm

Linux Command大全

Der Linux-Befehl comm wird verwendet, um zwei bereits sortierte Dateien zu vergleichen.

这项指令会一列列地比较两个已排序文件的差异,并将其结果显示出来,如果没有指定任何参数,则会把结果分成 3 This command will compare the differences between two sorted files column by column and display the results, and if no parameters are specified, the results will be divided 1 column is displayed: the 1 column is the column that appears only in the 2 column appears only in the 2 column is the column that appears only in the 3 column is the column that appears in the 1 and the 2 columns appeared in all the - is given, then the comm command will read data from the standard input device.

Syntax

comm [-123][--help][--version][the1files][the2files]

Parameter:

  • -1 do not display only in the 1 columns appeared in a file.
  • -2 do not display only in the 2 columns appeared in a file.
  • -3 do not display only in the 1 and the 2 columns appeared in a file.
  • --help Online help.
  • --version Display version information.

Online Examples

The file content of aaa.txt and bbb.txt is as follows:

[root@localhost text]# cat aaa.txt 
aaa 
bbb 
ccc 
ddd 
eee 
111 
222
[root@localhost text]# cat bbb.txt
bbb 
ccc 
aaa 
hhh 
ttt 
jjj

The output of the comm command is as follows:

[root@localhost text]# comm aaa.txt bbb.txt 
aaa
                bbb
                ccc
        aaa
ddd
eee
111
222
        hhh
        ttt
        jjj
First Column  Second Column  Third Column

The first column only contains columns that appear in aaa.txt, the second column contains columns that appear in bbb.txt, and the third column contains columns that appear in both aaa.txt and bbb.txt. The columns are separated by the tab character \t.

Linux Command大全