Question

So I'm looking for a pattern like this:

size='0x0'

in a log file - but I'm only interested in large sizes (4 digits or more). The following regex works great in EditPadPro (nice tool BTW)

size='0x[0-9a-fA-F]{4,}

But the same regex does not work in awk - seems like the repetition {4,} is messing it up. Same with WinGrep - any idea from the regex gurus? Thanks!

Was it helpful?

Solution

You can in fact use awk, with a caveat.

As mentioned on the following page, you need a special command-line option (--re-interval) to make it work out, since the interval expression (the {4,}) is not in the standard:

http://kansai.anesth.or.jp/gijutu/awk/gawk/gawk_28.html

So in the end, you'll want something that looks like:

awk --re-interval "/size='0x[0-9a-fA-F]{4,}'/" thefile

This will print out the lines that match.

OTHER TIPS

I don't know of any elegant alternatives to the {4,} syntax, but if it is not working in your desired environment you could resort to this ugly hack:

size='0x[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]+

Hope this helps!

Adam

Don't forget the last apostrophe.

'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top