version 1.54, 2020/06/26 21:50:06 |
version 1.55, 2020/06/27 14:04:58 |
|
|
This is convenient when working with multi-line records. |
This is convenient when working with multi-line records. |
.Pp |
.Pp |
An input line is normally made up of fields separated by whitespace, |
An input line is normally made up of fields separated by whitespace, |
or by the regular expression |
or by the value of the field separator |
.Va FS . |
.Va FS |
|
at the time the line is read. |
The fields are denoted |
The fields are denoted |
.Va $1 , $2 , ... , |
.Va $1 , $2 , ... , |
while |
while |
.Va $0 |
.Va $0 |
refers to the entire line. |
refers to the entire line. |
If |
|
.Va FS |
.Va FS |
is null, the input line is split into one field per character. |
may be set to either a single character or a regular expression. |
Lines are split into fields using the value of |
As as special case, if |
.Va FS |
.Va FS |
at the time the line is read. |
is a single space |
Because of this, |
.Pq the default , |
|
fields will be split by one or more whitespace characters. |
|
If |
.Va FS |
.Va FS |
is usually set via the |
is null, the input line is split into one field per character. |
.Fl F |
|
option or inside of a |
|
.Ic BEGIN |
|
block. |
|
.Pp |
.Pp |
Normally, any number of blanks separate fields. |
Normally, any number of blanks separate fields. |
In order to set the field separator to a single blank, use the |
In order to set the field separator to a single blank, use the |
|
|
.Fl F |
.Fl F |
option with a value of |
option with a value of |
.Sq [t] . |
.Sq [t] . |
|
The field separator is usually set via the |
|
.Fl F |
|
option or from inside a |
|
.Ic BEGIN |
|
block so that it takes effect before the input is read. |
.Pp |
.Pp |
A pattern-action statement has the form: |
A pattern-action statement has the form: |
.Pp |
.Pp |
|
|
.It Va FNR |
.It Va FNR |
Ordinal number of the current record in the current file. |
Ordinal number of the current record in the current file. |
.It Va FS |
.It Va FS |
Regular expression used to separate fields; also settable |
Regular expression used to separate fields (default whitespace); |
by option |
also settable by option |
.Fl F Ar fs . |
.Fl F Ar fs |
.It Va NF |
.It Va NF |
Number of fields in the current record. |
Number of fields in the current record. |
.Va $NF |
.Va $NF |