2

I often use awk to extract information from .csv files in BASH, including some with double quoted strings containing commas in certain fields - I came across a solution to this awk -vFPAT='([^,]*)|("[^"]+")' -vOFS=, on the page linked below but since I need to use it often, I'd like to add it as an alias in ~/.bashrc - Does anyone know a safe way I can do this? I'm worried that any solution would be bug-prone.

How to make awk ignore the field delimiter inside double quotes?

Thanks for any suggestions - I realise it might be better to leave this as a comment on the original post but Stackoverflow's reputation-based comment system prohibits this for me.

  • 1
    Since you're creating a function to do this, you might want to make it a shell script instead and use the more robust and portable awk script at [whats-the-most-robust-way-to-efficiently-parse-csv-using-awk](https://stackoverflow.com/questions/45420535/whats-the-most-robust-way-to-efficiently-parse-csv-using-awk) since it'll hande CSVs with fields that contain newlines and/or escaped double quotes and will work on platforms that don't have GNU awk. – Ed Morton Feb 15 '20 at 15:08

0 Answers0