version 1.46, 2020/01/22 03:47:38 |
version 1.47, 2020/06/10 21:00:01 |
|
|
option with a value of |
option with a value of |
.Sq [t] . |
.Sq [t] . |
.Pp |
.Pp |
A pattern-action statement has the form |
A pattern-action statement has the form: |
.Pp |
.Pp |
.D1 Ar pattern Ic \&{ Ar action Ic \&} |
.D1 Ar pattern Ic \&{ Ar action Ic \&} |
.Pp |
.Pp |
|
|
.Ic print |
.Ic print |
statement prints its arguments on the standard output |
statement prints its arguments on the standard output |
(or on a file if |
(or on a file if |
.Pf > Ar file |
.Pf >\ \& Ar file |
or |
or |
.Pf >> Ar file |
.Pf >>\ \& Ar file |
is present or on a pipe if |
is present or on a pipe if |
.Pf |\ \& Ar cmd |
.Pf |\ \& Ar cmd |
is present), separated by the current output field separator, |
is present), separated by the current output field separator, |
|
|
the same open file. |
the same open file. |
The |
The |
.Ic printf |
.Ic printf |
statement formats its expression list according to the format |
statement formats its expression list according to the |
|
.Ar format |
(see |
(see |
.Xr printf 1 ) . |
.Xr printf 1 ) . |
.Pp |
.Pp |
|
|
and |
and |
.Ic END |
.Ic END |
do not combine with other patterns. |
do not combine with other patterns. |
|
They may appear multiple times in a program and execute |
|
in the order they are read by |
|
.Nm . |
.Pp |
.Pp |
Variable names with special meanings: |
Variable names with special meanings: |
.Pp |
.Pp |
|
|
The length of |
The length of |
.Fa s |
.Fa s |
taken as a string, |
taken as a string, |
or of |
number of elements in an array for an array argument, |
|
or length of |
.Va $0 |
.Va $0 |
if no argument is given. |
if no argument is given. |
.It Fn match s r |
.It Fn match s r |
|
|
returns 1 for a successful input, 0 for end of file, and \-1 for an error. |
returns 1 for a successful input, 0 for end of file, and \-1 for an error. |
.It Xo |
.It Xo |
.Ic getline Op Va var |
.Ic getline Op Va var |
.Pf \ \&< Ar file |
.Pf <\ \& Ar file |
.Xc |
.Xc |
Sets |
Sets |
.Va $0 |
.Va $0 |
|
|
Executes |
Executes |
.Fa cmd |
.Fa cmd |
and returns its exit status. |
and returns its exit status. |
|
This will be \-1 upon error, |
|
.Ar cmd Ns 's |
|
exit status upon a normal exit, |
|
256 + |
|
.Em sig |
|
if |
|
.Fa cmd |
|
was terminated by a signal, where |
|
.Em sig |
|
is the number of the signal, |
|
or 512 + |
|
.Em sig |
|
if there was a core dump. |
.El |
.El |
.Ss Bit-Operation Functions |
.Ss Bit-Operation Functions |
.Bl -tag -width "lshift(a, b)" |
.Bl -tag -width "lshift(a, b)" |
|
|
.Pp |
.Pp |
.Dl { print $2, $1 } |
.Dl { print $2, $1 } |
.Pp |
.Pp |
Same, with input fields separated by comma and/or blanks and tabs: |
Same, with input fields separated by comma and/or spaces and tabs: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
BEGIN { FS = ",[ \et]*|[ \et]+" } |
BEGIN { FS = ",[ \et]*|[ \et]+" } |
{ print $2, $1 } |
{ print $2, $1 } |
|
|
.Ed |
.Ed |
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr cut 1 , |
.Xr cut 1 , |
|
.Xr grep 1 , |
.Xr lex 1 , |
.Xr lex 1 , |
.Xr printf 1 , |
.Xr printf 1 , |
.Xr sed 1 , |
.Xr sed 1 , |
|
|
.Pp |
.Pp |
The scope rules for variables in functions are a botch; |
The scope rules for variables in functions are a botch; |
the syntax is worse. |
the syntax is worse. |
|
.Pp |
|
POSIX-standard interval expressions in regular expressions are not supported. |
|
.Pp |
|
Only eight-bit character sets are handled correctly. |