Re:The Awk Programming Language, Second Edition
by asicsp on Thursday June 29, 2023 @10:05AM
(#36520507)
If quoted string is the only thing you need to handle extra (i.e. no escaped quotes, newlines, etc) and if you have GNU awk:
For a more robust solution, see https://stackoverflow.com/q/45420535 or use other tools like https://github.com/BurntSushi/xsv
[ Parent
| on HN ]
Re:The Awk Programming Language, Second Edition
by poetaster on Thursday June 29, 2023 @12:05PM
(#36522310)
I wanted to ask why not the more simple form:
echo '"foo","bar,baz","boo"' | awk -F"\",\"" '{print $1}' "foo
echo '"foo","bar,baz","boo"' | awk -F"\",\"" '{print $2}' bar,baz
echo '"foo","bar,baz","boo"' | awk -F"\",\"" '{print $3}' boo"
Realizing that I have to strip the quotes that remain.
Edit. formatting.
EDit, again, from your link, the following is more terse and too my taste (still needs strips):
awk -v FPAT='("[^"]*")+'