Awk supports quantifiers - I want [0-9] {6,6}

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

It corresponds to [0-9] [0-9] [0-9] [0-9] [0-9] [0-9] ok.

It does not seem to support \ d \ d \ d \ d \ d \ d.

I need to enable extended reg ex, or it just doesn't support this.

Tpx

+4
source share
2 answers

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> 
+10
source

With a minimal change in response Pax --posix also allows this behavior. In addition, you are correct that gawk does not support character class escape sequences (for example, \d ), but it does support the [[:digit:]] syntax.

+3
source

All Articles