Ignoring embeded spaces with AWK

后端 未结 4 1092
无人及你
无人及你 2020-12-20 08:40

I\'m looking for a simple way to print a specific field with awk while allowing for embedded spaces in the field.

Sample: Field1 Field2 \"Field Three\" Field

4条回答
  •  抹茶落季
    2020-12-20 09:29

    Parsing CSV can be a tricky business. I like to use a language with a proper CSV parsing module. For example with ruby, parsing the given line, using space as the column separator, and default double quotes quoting character:

    ruby -rcsv -ne 'row = CSV.parse_line($_, {:col_sep=>" "}); puts row[2]' <
    Field Three
    

提交回复
热议问题