Photo of Andy Arthur

Andy Arthur

It's the second half of November as the label job I ran today reminds me. 🏷️ The landscape is cold and barren, it's dark out for a good portion of day, and riding home in the dark isn't much fun. But you make the best of it, and I figure the extra sleep and time to learn isn't a bad thing. πŸ›Œ Next adventure after Thanksgiving! πŸ¦ƒ Hopefully the fire risk is down by then as I want to have a big bonfire in wilderness πŸ”₯ after a good day riding trail or hiking. 🚢

Comma Separated Fields (The GNU Awk User’s Guide)

Comma Separated Fields (The GNU Awk User’s Guide)

For decades, anyone wishing to work with CSV files and awk had to “roll their own” solution. (For an example, see Defining Fields by Content). In 2023, Brian Kernighan decided to add CSV support to his version of awk. In order to keep up, gawk too provides the same support as his version. To use CSV data, invoke gawk with either of the -k or --csv options.

Fields in CSV files are separated by commas. In order to allow a comma to appear inside a field (i.e., as data), the field may be quoted by beginning and ending it with double quotes. In order to allow a double quote inside a field, the field must be quoted, and two double quotes represent an actual double quote. The double quote that starts a quoted field must be the first character after the comma. Table 4.1 shows some examples.