multiple Field Separators in awk
awk, regex, string
Solution
Try doing this :
awk -F'}+|{+| ' '{for (i=1; i<=NF; i++) if ($i ~ "[0-9]") print $i}' file.txt
The Field Separator `FS` (the `-F` switch) can be a character, a word, a regex or a class of characters.
You can use this too :
awk 'BEGIN{FS="}+|{+| "} {for(i=1;i<=NF;i++) if($i ~ "[0-9]")print $i}' file.txt
explanations
- `foo|bar|base` is a regex where it can match any of the strings separated by the `|`
- in `}+|{+|`, we have the choice to match a literal `}` at least one : `+`, or a literal `{` at least one : `+`, or a space.
- you can use a class of character too to do the same : `[{} ]`, both works
Problem
i have this string ``` -foo {{0.000 0.000} {648.0 0.000} {648.0 1980.0} {0.000 1980.0} {0.000 0.000}} ``` i want to separate it to numbers and iterate over them ,thanks tried to use Field separator without success how can i do it with awk?