$1
, $2
, …, $(NF-1)
, $(NF)
.
NF
(Number of Fields) is the number of fields on each line (# columns in row).
$ echo "0 1:2,3 4" | awk -F"[:, ]" '{print "entries:" NF " first:" $1 " last:" $NF}'
$0
refers to the whole input row.
awk -F":" '{printf "user: %s\n whole line: %s\n", $1, $0}' /etc/passwd
printf
enables formatted printout - we will discuss in more details later.NR
(Number of Records) is the number of input records (lines):
$ awk 'END {print NR}' /etc/passwd
wc -l /etc/passwd