tags:

views:

221

answers:

2

gawk doesn't seem to match six digit fields - or n digit fields using the {n,m} quantifiers

It does match [0-9][0-9][0-9][0-9][0-9][0-9] ok.

Doesn't seem to support \d\d\d\d\d\d either.

Do i need to turn on extended reg ex, or does it just not support that.

Tnx

+5  A: 

You need to specify the "--re-interval" (or "-W re-interval") flag to take advantage of this behavior.

echo 12345 | gawk --re-interval '/[0-9]{5}/{print}{}'
12345
echo 12345 | gawk --re-interval '/[0-9]{6}/{print}{}'
<no output>
paxdiablo
+1  A: 

Expanding minimally on Pax's response, --posix also enables this behavior. Also, you are correct that gawk does not support the character class escapes (like \d) but it does support the [[:digit:]] syntax.

Sean Bright
sorry, I didn't see that you answered the second part about escape characters also. thanks