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

Linux comm command

Linux Command Manual

The Linux comm command is used to compare two sorted files.

This instruction 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 3 column displays: the 1 column appears only in the 1 column is the column that appears in the 2 column appears only in the 2 column is the column that appears in the 3 column is the column that appears in the 1 and the 2 columns appear 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 not displayed in the 1 columns appear in a file.
  • -2 not displayed in the 2 columns appear in a file.
  • -3 not displayed in the 1 and the 2 columns appear in a file.
  • --help Online help.
  • --version Display version information.

Online Examples

The file contents of aaa.txt and bbb.txt are 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 appearing in aaa.txt, the second column contains columns appearing in bbb.txt, and the third column contains columns appearing in both aaa.txt and bbb.txt. Columns are separated by tab \t.

Linux Command Manual