awk FS - Field Separator


Example

Used by awk to split each record into multiple fields:

echo "a-b-c
d-e-f" | awk 'BEGIN {FS="-"} {print $2}'

will result in:

b
e

The variable FS can also be set using the option -F:

echo "a-b-c
d-e-f" | awk -F '-' '{print $2}'

By default, the fields are separated by whitespace (spaces and tabs) and multiple spaces and tabs count as a single separator.