Latest web development tutorials

Linux comm command

Linux command Daquan Linux command Daquan

Linux comm command is used to compare two files have been sorted.

This directive will be one column to compare two sorted files of difference, and the result is displayed, if you do not specify any parameters, the result will be divided into 3 lines: Line 1 is only the first appears in a document column over a column, the second line is the only appears in the first two files off the first line 3 is in the 1st and 2nd file columns have appeared. If the file name is given as "-", the comm instruction data is read from the standard input device.

grammar

comm [-123][--help][--version][第1个文件][第2个文件]

Parameters:

  • -1 Is not displayed in the first column appears only one document before.
  • -2 Does not display the column only in the first two files before.
  • -3 Not display column appears only in the first and second document before.
  • --help online help.
  • --version display version information.

Examples

File contents aaa.txt and bbb.txt 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
<p>执行 comm 命令输出结果如下:</p>
[root@localhost text]# comm aaa.txt bbb.txt 
aaa
                bbb
                ccc
        aaa
ddd
eee
111
222
        hhh
        ttt
        jjj
第一列  第二列  第三列

The first column contains only output that appears in aaa.txt row, the second row contains the column that appears in bbb.txt, the third column contains aaa.txt and bbb.txt in the same row. Each column is the tab character (\ t) as delimiters.

Linux command Daquan Linux command Daquan