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,
awk(1) on FreeBSD does not recognize --field-separator. Use -v instead:
--field-separator
-v
echo "a b c d" | awk -v FS=" " "{ print NF }"
It is a portable, POSIX way to define the field separator.