Data file - data.txt:
ABC \"I am ABC\" 35 DESC
DEF \"I am not ABC\" 42 DESC
cat data.txt | awk \'{print $2}\'
will re
Another alternative would be to use the FPAT variable, that defines a regular expression describing the contents of each field.
Save this AWK script as parse.awk
:
#!/bin/awk -f
BEGIN {
FPAT = "([^ ]+)|(\"[^\"]+\")"
}
{
print $2
}
Make it executable with chmod +x ./parse.awk
and parse your data file as ./parse.awk data.txt
:
"I am ABC"
"I am not ABC"