Friday, October 12, 2018

awk delimiters

I have been using awk for a while and I had a use case where I wanted to use multiple delimiter, ' ' being one of them.
If its just space, we can use :
awk -F' ' '{print $2}'
If its bunch of characters, we can use :
awk -F'[.:]' '{print $2}' 

But with space, we need to use as follows :
awk -F'[[:space:].]+' '{print $2}'

I have not been able to figure out to associate '+' only to space. But for now this will server the purpose as long as I can combine multiple '.'

Some other classes are:
[[:blank:][:cntrl:]] 
[ \t,:;]