AWK to use multiple spaces as delimiter

后端 未结 2 1497
甜味超标
甜味超标 2021-02-19 01:58

I am using below command to join two files using first two columns.

awk \'NR==FNR{a[$1,$2]=substr($0,3);next} ($1,$2) in a{print $0, a[$1,$2] > \"br0102_3.tx         


        
2条回答
  •  花落未央
    2021-02-19 02:41

    awk supports a regular expression as the value of FS so you can specify a regular expression that matches at least two spaces. Something like -F '[[:space:]][[:space:]]+'.

    $ awk '{print NF}' File2
    4
    3
    4
    
    $ awk -F '[[:space:]][[:space:]]+' '{print NF}' File2
    3
    3
    3
    

提交回复
热议问题