美文网首页
awk实现两个文件中数据集求同异V

awk实现两个文件中数据集求同异V

作者: 赵会成 | 来源:发表于2019-03-08 20:03 被阅读0次

1.在B中同时也在A中,comm_a_b.sh

sort -u A > /tmp/A.txt

sort -u B > /tmp/B.txt

awk 'NR==FNR{a[$1]=$2} NR>FNR {if($1 in a){print $0}}' /tmp/A.txt /tmp/B.txt > /tmp/result.txt

2.在B中,不在A中,diff_in_b_not_in_a.sh

sort -u A > /tmp/A.txt

sort -u B > /tmp/B.txt

awk 'NR==FNR{a[$1]=$2} NR>FNR {if(!($1 in a)){print $0}}' /tmp/A.txt /tmp/B.txt > /tmp/result.tx

https://blog.csdn.net/lavorange/article/details/80410290

相关文章

网友评论

      本文标题:awk实现两个文件中数据集求同异V

      本文链接:https://www.haomeiwen.com/subject/qsudpqtx.html