I'm not sure what I'm doing wrong. Given a test.log of:
123.123.123.123 321.321.321.321 GET /test1234/asdfasdfpioasdfjkhweris,9
123.123.123.123 321.321.321.321 GET /4321test/asdfasdfpioasdfjkhweris,9
123.123.123.123 321.321.321.321 GET /test123456/asdfasdfpioasdfjkhweris,9
I am trying to isolate the first two by specifying the number of characters between the / and /.
This works
cat test* | awk '{if($4 ~ /^\/[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]\//) print $0}'
But this does not
cat test* | awk '{if($4 ~ /^\/[a-zA-Z0-9]{8,}\//) print $0}'
What am I missing?
I've also tried:
cat test* | awk '$4 ~ /^\/[a-zA-Z0-9]{8}\// {print $0}'
which didn't work either.
UPDATE: I also tried the same commands using gawk, which is also available for me to use, and they still didn't work.
mawk
? It looks likemawk
doesn't support the{m,n}
syntax at all. Try using a more full featured implementation like GNU'sgawk
.awk
commands work for me (with GNUawk
4.x). (Olderawk
s may not have supported the brace quantifiers.) - Unrelated, but BTW, you should omit thecat
and letawk
open the files:awk ' ... ' test*
.