Awk substring falls between two values

Hi guys, hopefully you can give me a hand with this before my monitor has a nasty accident! :mad:

I have the following line in a script:

awk 'int(substr($1,2,2))>'06' && int(substr($1,2,2))<'08' ' ANYOLDFILE.log

... which when ran against this data file:

[07:50:37,459] [Some stuff] [Some more stuff]
[08:13:37,459] [Some stuff] [Some more stuff]

... correctly returns:

[07:50:37,459] [Some stuff] [Some more stuff]

But I can't work out for the life of me the syntax to use a variable string instead of the values '06' and '08'. I've tried every combination I can think of but none of them work. I don't get an error, but it doesn't return any data.

Anyone know what the answer is?

Also I have been forced to ask for results between 6 and 8 because I couldn't manage to get it to do a simple check for =7, so if you know how to do that as well, you'll get a double dose of karma for the day!

Thanks in advance. :b:

First of all, what's wrong with:

v=7
grep "^\[0*$v" infile

In Awk it would be:
(use nawk or /usr/xpg4/bin/awk on Solaris)

awk '$0 ~ p' p="^[[]0*7" infile

Absolutey nothing wrong with that it works like a charm thanks. Does the ^ on both examples indicate a start of line?

Yes.

(message too short)