Hi,
I have a small query when comparing two files with awk. I have a small piece of code running in a shell. See below:
gawk -F"," 'NR == FNR { A[$1","$2","$3","$4]=1; next } \!A[$1","$2","$3","$4]' OFS="," 2011.csv 2012.csv > diff_2012.csv
The code works fine (Note I had to escape the ! with \! to run in shell). What I want to do is add a loop to this code. For the array I want to keep columns $1, $2, $3 for each loop and increment $4 to become $5 then $6 etc up to $33. Each pass of the loop I want to output the difference to a new csv file. An example of what i want is:
gawk -F"," 'NR == FNR { A[$1","$2","$3","$5]=1; next } \!A[$1","$2","$3","$5]' OFS="," 2011.csv 2012.csv > diff_2012_5.csv
Then
gawk -F"," 'NR == FNR { A[$1","$2","$3","$6]=1; next } \!A[$1","$2","$3","$6]' OFS="," 2011.csv 2012.csv > diff_2012_6.csv
etc etc. Only I want the above in a loop.
Thanks in advance for your help