Number of fields returned by awk

后端 未结 4 1661
抹茶落季
抹茶落季 2021-02-03 23:50

Is there a way to get awk to return the number of fields that met a field-separator criteria? Say, for instance, my file contains

a b c d

so,

4条回答
  •  鱼传尺愫
    2021-02-04 00:10

    NF gives the number of fields for a given record:

    []$ echo "a b c d" | gawk '{print NF}'
    4
    

提交回复
热议问题