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
哪位大拿有高招?试了无数次,恼火的很。