Operating System - HP-UX
1753259 Members
5766 Online
108792 Solutions
New Discussion юеВ

Re: grep regular expression performance

 
Jim Wagner_2
Occasional Contributor

grep regular expression performance

Hi,
Running OSF1 5.1 732:

the following egrep is designed to match a quoted string, possibly containing escaped quotes (\") or other escaped characters.
egrep '"([^\"]+|\\.)*"'
This works fine for small matches like
"abc"
but for longer matches like
"abc abc abc abc abc abc abc abc "
performance degrades severely.
On Sun and other platforms this works fine.

Same problem exists using regexec()
Has anyone seen this before, and is it fixed in a patch?
Alternatively, any workaround?

4 REPLIES 4
Jov
Honored Contributor

Re: grep regular expression performance

Hi,
Have you tried "awk", "gawk" or other *awk(s)? awk has better RE then grep|egrep.

Anyway, to answer your question, for strings like "abc abc abc abc abc abc abc abc", I would use egrep '^abc'. This will match the the first "abc" and move on. But I know this will be a very narrow solution.

Also "sed" has a "g" flag or tag which matches globally for the string, thus without this, it will only match the first instance. Give it a try.


Rdgs

Jov
Hein van den Heuvel
Honored Contributor

Re: grep regular expression performance



Wrong Forum.


OSF1 5.1 732 is a 4 year old Tru64 version nicknamed Zulu.

You probably want to retry after moving to a more recent (V5.1B?) baselevel, or at least with a recent patch kit.


fwiw,
Hein.
Jov
Honored Contributor

Re: grep regular expression performance

Hi Hein,

Don't be too harsh. HP-UX admins will experience similar problems if HP merge more Tru64 features/fails. ;)


Cheers

Jov
Jim Wagner_2
Occasional Contributor

Re: grep regular expression performance

[re-posted to Tru64 forum]