Ignoring embeded spaces with AWK

后端 未结 4 1094
无人及你
无人及你 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:08

    Based on this, in gawk maybe you can use something like

    awk 'BEGIN{FPAT = "([^ ]+)|(\"[^\"]+\")"}{print $3}' input.txt
    

    Output:

    "Field Three"
    

    It may need more work to get suited to your needs completely.

    I think it needs gawk 4+, https://lists.gnu.org/archive/html/info-gnu/2011-06/msg00013.html

提交回复
热议问题