有多个文件,每个文件都有交集。 现在要将每个文件去重。
这里使用到3个命令:cat、sort、uniq
cat查看文件内容
sort排序
uniq去重
1. 取几个文件的并集
cat fileA fileB fileC | sort | uniq
➜ test cat test1
a1
a2
a3
a1
➜ test sort test1
a1
a1
a2
a3
➜ test sort test1 | uniq
a1
a2
a3
2. 取几个文件的交集
cat fileA fileB fileC | sort | uniq -d
➜ test sort test1 | uniq -d
a1
3. 取几个文件不重复的部分
cat fileA fileB fileC | sort | uniq -u
➜ test sort test1 | uniq -d
a1