These command-line options reduce the output:
- -1: Removes the first column
- -2: Removes the second column
- -3: Removes the third column
The set difference operation enables you to compare two files and print all the lines that are in the A.txt or B.txt file excluding the common lines in A.txt and B.txt. When A.txt and B.txt are given as arguments to the comm command, the output will contain column-1 with the set difference for A.txt with regard to B.txt and column-2 will contain the set difference for B.txt with regard to A.txt.
The comm command will accept a - character on the command line to read one file from stdin. This provides a way to compare more than one file with a given input.
Suppose we have a C.txt file, like this:
$> cat C.txt
pear
orange
silver
mithral
We can compare the B.txt and C.txt files with A.txt, like this:
$> sort B.txt C.txt | comm - A.txt
apple
carrot
cookies
gold
iron
mithral
orange
pear
silver
steel