Number of fields returned by awk

The NF variable is set to the total number of fields in the input record. So:

echo "a b c d" | awk --field-separator=" " "{ print NF }"

will display

4

Note, however, that:

echo -e "a b c d\na b" | awk --field-separator=" " "{ print NF }"

will display:

4
2

Hope this helps, and happy awking

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)