Mac OS X awk (BSD awk ) works with the first command:
$ echo "123" | /usr/bin/awk '/^[0-9]{3}$/ {print $1;}' 123 $
GNU awk no. Adding backslashes does not help GNU awk . Using the --re-interval option does, and also uses --posix .
$ echo "123" | /usr/gnu/bin/awk --re-interval '/^[0-9]{3}$/ {print $1;}' 123 $ echo "123" | /usr/gnu/bin/awk --posix '/^[0-9]{3}$/ {print $1;}' 123 $
(I'm not sure where mawk 1.3.3 from 1996 came from, but it's probably time to get an updated version of awk for your machine.)
source share