A(1,2,3)和B(3,4,5)，A和B的交集是3，A对B的差集是1和2，B对A的差集是4和5，A和B求差的结果是1、2、4、5。

[[email protected] tmp]# cat <<eof>set1.txt > orange > gold > apple > sliver > steel >
iron> eof [[email protected] tmp]# cat <<eof>set2.txt > orange > gold > cookiee >
carrot> eof

[[email protected] tmp]# comm set1.txt set2.txt apple orange comm: file 1 is not in
sorted order comm:file 2 is not in sorted order gold cookiee carrot silver
steel iron

[[email protected] tmp]# sort set1.txt -o set1.txt;sort set2.txt -o set2.txt
[[email protected] tmp]# comm set1.txt set2.txt apple carrot cookiee gold iron orange
silver steel

[[email protected] tmp]# comm set1.txt set2.txt -1 -2 gold orange
A对B的差集就是第一列，B对A的差集就是第二列。
[[email protected] tmp]# comm set1.txt set2.txt -2 -3 # A对B的差集 apple iron silver steel
[[email protected] tmp]# comm set1.txt set2.txt -1 -3 # B对A的差集 carrot cookiee
A和B的求差就是第一列和第二列的组合。
[[email protected] tmp]# comm set1.txt set2.txt -3 apple carrot cookiee iron silver
steel

[[email protected] tmp]# comm set1.txt set2.txt -3 | tr "\t" "\0" apple carrot