Penguin
Note: You are viewing an old revision of this page. View the current version.

The Field Separator

It doesn't just have to white space between fields. In can be anything as long as you set the appropriate field separator. Eg:

  • echo "123:456:789" | awk -F ':' '{print $1,$2,$3,}'

The : after the -F tells us that : is the input field separator. Change this as appropriate.

Multiple Field Separators.

What if there are multiple characters you wish to use as field separators? After the -F just list all of the characters in square brackets. For example:

  • echo "123:456=789" | awk -F '[:=]' '{print $1,$2,$3}'