what happen when using $1
, $2
... in end
block, like:
awk '{print $3}end{print $1 $2}'
i found $1
, $2
retain values last record. behaviour guaranteed standard or implementation-specific?
checking docs see implementation-specific:
traditionally, due largely implementation issues, $0 , nf undefined inside end rule. posix standard specifies nf available in end rule. contains number of fields last input record. due oversight, standard not $0 preserved, although logically 1 think should be. in fact, of bwk awk, mawk, , gawk preserve value of $0 use in end rules. be aware, however, other implementations , many older versions of unix awk not.
Comments
Post a Comment