Parse CSV with quotes (gawk)
Parse quoted CSV fields correctly with FPAT in gawk
gawk -v FPAT='([^,]+)|("[^"]+")' '{print $2}' data.csv
- tool
- awk15 commands
More awk commands
-
awk 'BEGIN{print "Start"} {lines++} END{print lines" lines processed"}' file.txtRun code before and after all lines are processed
-
awk 'NR==FNR{a[$1]=$2; next} $1 in a {print $0, a[$1]}' lookup.txt data.txtJoin data.txt with lookup.txt on the first field; lines without a match are skipped
-
awk '{print $3}' file.txtPrint the 3rd field, split by whitespace
-
awk -F: '{print $1, $3}' /etc/passwdUse a colon as the separator and print the user name and UID
-
awk '/ERROR/ {print NR": "$0}' app.logPrint the line number and text of lines with ERROR