我有以下CSV:AWK使用文件,刪除CSV行
old.csvirrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
,我需要刪除含有該文件的電子郵件行:
remove.txt
[email protected]
[email protected]
[email protected]
[email protected]
而且我需要的輸出是這樣的:
new.csv
irrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
irrelevant,irrelevant,[email protected],irrelevant
我已經試過這一點,但它不工作。誰能幫忙?
awk -F, 'BEGIN{IGNORECASE = 1};NR==FNR{remove[$1]++;next}!($1 in remove)' remove.txt old.csv > new.csv
可以嘗試更改'($ 1刪除)''到(在刪除了$ 3)'?實際上你可以做'!remove [$ 3]'。如果遇到問題,可以使用'toupper/lower()'函數 – Kent