Escaping separator within double quotes, in awk
I am using awk to parse my data with "," as separator as the input is a csv file. However, there are "," within the data which is escaped by double quotes ("..."). Example filed1,filed2,field3,"field4,FOO,BAR",field5 How can i ignore the comma "," within the the double quote so that I can parse the output correctly using awk? I know we can do this in excel, but how do we do it in awk? Dimitre Radoulov It's easy, with GNU awk 4 : zsh-4.3.12[t]% awk '{ for (i = 0; ++i <= NF;) printf "field %d => %s\n", i, $i }' FPAT='([^,]+)|("[^"]+")' infile field 1 => filed1 field 2 => filed2 field 3 => field3