How can I use double quotes as a field separator?
awk -v val=$num 'BEGIN { FS='"';}{}'
I am using above statement however encountered an error.
Just put your desired field separator with the -F option in the AWK command and the column number you want to print segregated as per your mentioned field separator. Show activity on this post. AWK works as a text interpreter that goes linewise for the whole document and that goes fieldwise for each line.
The field separator, which is either a single character or a regular expression, controls the way awk splits an input record into fields. awk scans the input record for character sequences that match the separator; the fields themselves are the text between the matches.
AWK: Change Field Separator By default, awk uses both space and tab characters as the field separator. You can tell awk how fields are separated using the -F option on the command line.
The default field delimiter or field separator (FS) is [ \t]+ , i.e. one or more space and tab characters.
Two ways:
awk -v val=$num -F'"' '{}'
awk -v val=$num 'BEGIN { FS="\"";}{}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With