awk Built-in Variables FS - Field Separator

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any awk Question?