I have a file in the following format:
field1|field2|field3
field1|"field2|field2"|field3
Notice the second row contains double quotes. The string within the double quotes belongs to field 2. How do extract this using awk? I've been googling with no results. I tried this with no luck as well
FS='"| "|^"|"$' '{print $2}'
Best Answer
If you have a recent version of
gawk
you're in luck. There's theFPAT
feature, documented here