Skip to content

Instantly share code, notes, and snippets.

@pureugong
Created October 15, 2019 06:59
Show Gist options
  • Select an option

  • Save pureugong/f34ba4da9200b97dd93a683c8cc701b0 to your computer and use it in GitHub Desktop.

Select an option

Save pureugong/f34ba4da9200b97dd93a683c8cc701b0 to your computer and use it in GitHub Desktop.
how to parse csv with awk, which has "new lines within double quotes"
cat << EOF > /tmp/sample.csv
"one",
"three
four",
"seven"
EOF
gawk -v RS='"' 'NR % 2 == 0 { gsub(/\n/, "") } { printf("%s%s", $0, RT) }' /tmp/sample.csv | awk -F, '{print $1}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment