Search code examples
linuxshellawkseparator

How to set different separator with \s in awk?


text(After 1 is blank(space \t\f\v) ):

1    23.4,56

I want result of print $3 is 4. But run echo "1 23.4,56" | awk -F'[\\s+|,|.]' '{print $3}' , result is 56


Solution

  • I want result of print $3 is 4.

    Some changes to FS and your code can get it:

    echo "1    23.4,56" | awk -F'[,.]|[[:blank:]]+' '{print $3}'
    4