Built-in variables in AWK
Variables play an important role when creating AWK scripts and programs. They modify the behavior of AWK commands. AWK built-in variables have uppercase names. These built-in variables can be used in all expressions, and can be reset by the user. They are set automatically. The following sections discuss the different built-in variables in AWK.
Field separator
The field separator (FS) is either a single character or a regular expression. It decides the way AWK splits an input record into fields. The FS
is represented by the built-in variable FS
, and its default value is a single space. It tells AWK to separate fields across any number of spaces and/or tabs.
Using a single character or simple string as a value of the FS
Fields are normally separated by whitespace sequences (spaces, tabs, and newlines). In this case, leading and trailing whitespaces (spaces or tabs) are stripped from the current input line, and fields are separated by a space or a tab. The AWK default...