利用sort和uniq求两个文件的并集,交集和差集

 利用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

相关文章
相关标签/搜索