利用sort和uniq求兩個文件的並集,交集和差集ide
並集:cat file1.txt file2.txt | sort | uniq > file.txtspa
交集:cat file1.txt file2.txt | sort | uniq -d >file.txtorm
差集:求file1.txt相對於file2.txt的差集,可先求出二者的交集file3.txt,而後在file1.txt中除去file3.txt便可。it
cat file1.txt file2.txt | sort | uniq -d > file3.txtclass
cat file1.txt file3.txt | sort | uniq -u >file.txtfile