求救:shell script/awk question

來源: 貝加兒湖畔 2018-04-25 18:13:18 [] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (609 bytes)
I have one .csv file “file1” of 3 columns. And another file “file2” of 4 columns. I want to compare the first 3 columns of these two files and print out lines in file 2 where the first 3 columns don’t exist in file 1. This is my code: awk -F”,” ‘NR==NFR{a[$1,$2,$3]=$1$2$3;next} {if(!a[$1,$3,$3]=$1$2$3) {print $0}}’ file1 file2 If the files are delimited by space, the script works. It just doesn’t work for csv. similarly, egrep works fine if the delimiter of the files is space, but not csv files. egrep -vf file1 file2 哪位大拿有高招?試了無數次,惱火的很。

所有跟帖: 

改成shell script笨辦法解決問題了。謝謝 -貝加兒湖畔- 給 貝加兒湖畔 發送悄悄話 (0 bytes) () 04/25/2018 postreply 20:31:35

請您先登陸,再發跟帖!