Artificial intelligent assistant

awk character class mystery I seem to be unable to use a character class for an **awk** regular expression, almost exactly as described here : user@host:~$ awk -W version mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan compiled limits: max NF 32767 sprintf buffer 2040 user@host:~$ echo "host.company.com has address 192.168.22.82" |awk '/^[a-zA-Z0-9.-]+ has address/ { print $4 }' 192.168.22.82 user@host:~$ echo "host.company.com has address 192.168.22.82" |awk '/^[[:alnum:].-]+ has address/ { print $4 }' user@host:~$ Does anyone see why the second command fails to find the address field?

It's a bug in `mawk 1.3.3` and was reported here. You can upgrade to `mawk 1.3.4` or use patch to fix the bug.


$ mawk -W version
mawk 1.3.4 20130219
Copyright 2013, Thomas E. Dickey
Copyright 1996, Michael D. Brennan

internal regex
compiled limits:
max NF 32767
sprintf buffer 2040

$ echo "host.company.com has address 192.168.22.82" | mawk '/^[[:alnum:].-]+ has address/ { print $4 }'
192.168.22.82


`mawk` uses extended regular expressions as with `egrep`, so it must support POSIX characters classes.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3d3a5912b7cb9a418fe1ae1ce23a7422