Get union, intersection and difference of 2 files with 1 line command
巧用
sort
和uniq
得到两个文件的交集、并集、差集
$ cat A
aa
bbb
1.1.11.1
2.2.2.2
$ cat B
2.2.2.2
bbb
ccc
ddd
10.10.10
并集 union
sort A B |uniq
交集 intersection
sort A B |uniq -d
差集 difference
A - B
sort A B B |uniq -u
B - A
sort B A A |uniq -u
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here