shell 文件处理 并集 交集 差集(1个是另一个的子集时候才能用)
1. 取出两个文件的并集(重复的行只保留一份)
cat file1 file2 | sort | uniq
2. 取出两个文件的交集(只留下同时存在于两个文件中的文件)
cat file1 file2 | sort | uniq -d
3. 删除交集,留下其他的行
cat file1 file2 | sort | uniq -u
4、计数
cat file1 file2 | sort | uniq -c 可以将相同行数的计数放在行首