Perl. Commands AWK commands are the statements that are substituted for action in the examples above. AWK commands can include function calls, variable assignments, calculations, or any combination thereof. AWK contains built-in support for many functions; many more are provided by the various flavors of AWK. Also, some flavors support the inclusion of dynamically linked libraries, which can also provide more functions. The print command The print command is used to output text. The output text is always terminated with a predefined string called the output record separator (ORS) whose default value is a newline. The simplest form of this command is: print This displays the contents of the current record. In AWK, records are broken down into fields, and these can be displayed separately: print $1 Displays the first field of the current record print $1, $3 Displays the first and third fields of the current record, separated by a predefined string called the output field separator (OFS) whose default value is a single space character Although these fields ($X) may bear resemblance to variables (the $ symbol indicates variables in Perl), they actually refer to the fields of the current record. A special case, $0, refers to the entire record. In fact, the commands "print" and "print $0" are identical in functionality. The print command can also display the results of calculations and/or function calls: /regex_pattern/ { # Actions to perform in the event the record (line) matches the above regex_pattern print 3+2 print foobar(3) print foobar(variable) print sin(3-2) } Output may be sent to a file: /regex_pattern/ { # Actions to perform in the event the record (line) matches the above regex_pattern print "expression" > "file name" } or through a pipe: /regex_pattern/ { # Actions to perform in the event the record (line) matches the above regex_pattern print "expression" | "command" } Built-in variables Awk's built-in variables include the field variables: $1, $2, $3, and so on ($0 represents the entire record). They hold the text or values in the individual text-fields in a record. Other variables include: NR: Number of Records. Keeps a current count of the number of input records read so far from all data files. It starts at zero, but is never automatically reset to zero. FNR: File Number of Records. Keeps a current count of the number of input records read so far in the current file. This variable is automatically