I'm trying to match repeated patterns in strings. I know i can use /^[0-9]{5}$/
at least in perl, but this doesn't seem to work in awk or nawk (no gawk installed).
Any alternative, other than /^[0-9][0-9][0-9][0-9][0-9]$/
?
EDIT:
echo "AAB" > test
script.awk:
#!/usr/bin/nawk -f
BEGIN {}
/^A\{2,2\}/ { print "1"; }
/^A/ { print "2"; }
/A\{2,2\}/ { print "3"; }
/A{2,2}/ { print "4"; }
END {}
./script.awk test
only output (awk or nauk):
2
The default awk on Solaris is old, broken awk which should never be used by anyone for any reason. nawk is much better than /usr/bin/awk but is still a very old, non-POSIX awk, and so does not support RE intervals. Almost any other awk will work. On Solaris if you don't have and can't install GNU awk then use /usr/xpg4/bin/awk as it's very close to POSIX compliant and does support RE intervals.