ubuntu中命令行求csv文件的交集和差集

ubuntu中命令行求csv文件的交集和差集

sort 差集

sort -m <(sort big.csv | uniq) <(sort small.csv | uniq) <(sort small.csv | uniq) | uniq -u  > different_set_bySort.csv

grep 交集
功能:可以把文件2中存在文件1的行输出

grep -F -f big.csv small.csv > intersection_byGrep.csv

grep 差集

#注意,是 big - small 的结果
grep -F -v -f small.csv big.csv > difference_set_byGrep.csv