This command compares the differences between two sorted files in one column and displays the results. If no parameter is specified, the results are divided into three lines: rows 1st are only columns that have appeared in 1st files, and rows 2nd are columns that have only appeared in 2nd files, rows 3rd are columns that appear in files 1st and 2nd. If the given file name is "-", The comm command reads data from the standard input device.
Syntax
Comm [-123] [-- help] [-- version] [1st files] [2nd files]
Parameters:
- -1 does not show columns that appear only in 1st files.
- -2 do not show columns that appear only in 2nd files.
- -3: columns that appear only in files 1st and 2nd are not displayed.
- -- Help online help.
- -- Version: displays the version information.
Instance
The content of aaa.txt and bbb.txt files 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
<P> The output result of executing the comm command is as follows: </p>
[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 same row in rows. Each column uses a tab (\ t) as the delimiter.