bashawk

How can I use ":" as an AWK field separator?


Given the following command,

echo "1: " | awk '/1/ -F ":" {print $1}'

why does AWK output:

1:

?


Solution

  • -F is a command line argument, not AWK syntax. Try:

    echo '1: ' | awk -F  ':' '/1/ {print $1}'