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

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容