2个文件之间的差异(awk)

阿努阿尔

我尝试了 Stack Overflow 的许多解决方案,但没有一个令人满意的结果。我有2个文件,并希望删除从项file1被提及file2

文件 1

1,[email protected],9
9,[email protected],1
8,[email protected],6
2,[email protected],1
15,[email protected],3
6,[email protected],1

文件 2

[email protected]
[email protected]
[email protected]
[email protected]

结果

1,[email protected],9
8,[email protected],6
2,[email protected],1
6,[email protected],1

请问你能帮帮我吗?我失败的尝试:

awk -F',' 'NR==FNR{c[$1]++;next};c[$2] > 0' file2 file1
拉文德辛格13

尝试关注 awks,如果这对您有帮助,请告诉我。

解决方案一:

awk 'FNR==NR{a[$0];next} ($2 in a){next} 1' File2 FS="," File1

解决方案二:

awk 'FNR==NR{a[$0];next} !($2 in a)' File2 FS="," File1

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章