参照:http://blog.csdn.net/yinxusen/article/details/7450213
集合A = {a, b, c}
集合B = {d, e, c, b}
$ man uniq
With no options, matching lines are merged to the first occurrence.
-d, --repeated
only print duplicate lines
-u, --unique
only print unique lines
1. 求并集 A + B
>sort A B | uniq
a
b
c
d
e
2. 求交集:
>sort A B | uniq -d
b
c
>sort A B B | uniq -u
a
4. 求差集 B - A
>sort A B A | uniq -u
d
e