awk performs a number of actions automatically when it parses lines: it updates the variable NF, which contains the number of fields on a line; and it parses the record into a series of fields which are accessible via the variables $1, $2, $3 and so on. The variable $0 contains the entire line. Though you might consider $1 as a variable, it's not exactly true, in fact $ is the field reference operator and 1 is just a number that tells awk you want to reference the first field. They behave a bit like an array ie where with an array you would write fields[1] in awk you write $1 You can replace 1 by an expression, thus $(10-9) also refers to first field. Since the variable NF contains the number of fields on a line, and since fields are indexed starting from 1, $(NF) (or just $NF) contains the last field in any given record. For those who won't take the time to read this whole faq {{{ awk print $1 # prints the first field print $(10-9) # again the first field i=1;print $i # yes it prints the first field print $NF # prints the last field print $(NF-1) # prints the field before the last one }}} (Note that you can assign these fields, but that's another story See the GNU awk manual entries for..: * [http://www.gnu.org/software/gawk/manual/html_node/Auto_002dset.html|Built-in Variables that convey information]; * [http://www.gnu.org/software/gawk/manual/html_node/Fields.html|Examining fields]
Summary:
This change is a minor edit.
Username: