version 1.14, 2003/09/02 18:50:06 |
version 1.15, 2003/11/24 10:58:08 |
|
|
.Pp |
.Pp |
An action is a sequence of statements. |
An action is a sequence of statements. |
A statement can be one of the following: |
A statement can be one of the following: |
.Pp |
|
.Bd -unfilled -offset indent |
.Bd -unfilled -offset indent |
.Ic if ( Xo |
.Ic if ( Xo |
.Ar expression ) statement \& |
.Ar expression ) statement \& |
|
|
.Fn atan2 |
.Fn atan2 |
are built in. |
are built in. |
Other built-in functions: |
Other built-in functions: |
.Pp |
|
.Bl -tag -width Fn |
.Bl -tag -width Fn |
.It Fn length |
.It Fn length |
the length of its argument |
the length of its argument |
|
|
A pattern may consist of two patterns separated by a comma; |
A pattern may consist of two patterns separated by a comma; |
in this case, the action is performed for all lines |
in this case, the action is performed for all lines |
from an occurrence of the first pattern |
from an occurrence of the first pattern |
though an occurrence of the second. |
through an occurrence of the second. |
.Pp |
.Pp |
A relational expression is one of the following: |
A relational expression is one of the following: |
.Bd -unfilled -offset indent |
.Bd -unfilled -offset indent |
|
|
.Ar \& array-name |
.Ar \& array-name |
.Xc |
.Xc |
.Ed |
.Ed |
|
.Pp |
where a |
where a |
.Ar relop |
.Ar relop |
is any of the six relational operators in C, and a |
is any of the six relational operators in C, and a |
|
|
.Pp |
.Pp |
.Dl { print $2, $1 } |
.Dl { print $2, $1 } |
Print first two fields in opposite order. |
Print first two fields in opposite order. |
.Pp |
|
.Bd -literal -offset indent |
.Bd -literal -offset indent |
BEGIN { FS = ",[ \et]*|[ \et]+" } |
BEGIN { FS = ",[ \et]*|[ \et]+" } |
{ print $2, $1 } |
{ print $2, $1 } |
.Ed |
.Ed |
Same, with input fields separated by comma and/or blanks and tabs. |
Same, with input fields separated by comma and/or blanks and tabs. |
.Pp |
|
.Bd -literal -offset indent |
.Bd -literal -offset indent |
{ s += $1 } |
{ s += $1 } |
END { print "sum is", s, " average is", s/NR } |
END { print "sum is", s, " average is", s/NR } |
|
|
.Pp |
.Pp |
.Dl /start/, /stop/ |
.Dl /start/, /stop/ |
Print all lines between start/stop pairs. |
Print all lines between start/stop pairs. |
.Pp |
|
.Bd -literal -offset indent |
.Bd -literal -offset indent |
BEGIN { # Simulate echo(1) |
BEGIN { # Simulate echo(1) |
for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i] |
for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i] |