uniq - report or omit repeated lines
并集:cat file1.txt file2.txt | sort | uniq > file.txt
交集:cat file1.txt file2.txt | sort | uniq -d >file.txt
差集:求file1.txt相对于file2.txt的差集,可先求出两者的交集temp.txt,然后在file1.txt中除去temp.txt即可。
cat file1.txt file2.txt | sort | uniq -d >temp.txt
cat file1.txt temp.txt | sort | uniq -u >file.txt
原文:https://www.cnblogs.com/jmliao/p/12133924.html