I need to parse some CSV and there is a limitation that it has to be awk/bash. The below is the best I got, but it returns
Ecology",Biology
but I would need "PhD, Ecology". Any help would be very much appreciated!
echo '6,John Smith,"PhD, Ecology",Biology Department' |
awk 'BEGIN{FPAT = "\"[^\"]*\"|[^,]*"} {print $3}'
The similar question here did not help me: Parse a csv using awk and ignoring commas inside a field
awk version 20200816
MacOS.
GNU Awk 5.1.0awk --versionawk version 20200816. Will check if I can get a different version.gawkinstead works fine, thanks a lot for the comment!!!brew install gawk