On Fri, 30 Jul 2004, Andrew Gaffney wrote:

I think it is a problem with the regex. If I change it to:

grep -RLi '<%init>' * | grep '.html'

I get all files that don't have '<%init>', but it doesn't work with the '<%(init|perl)>'. That regex doesn't seem to match anything.

More man page material: I was using `egrep` for the earlier examples, not `grep`. On my computer (a Mac), `egrep` is equivalent to `grep -e`; either way, this pulls in an enhanced regex parser that, in this case, is being used to match multiple patterns (by|doing|this).


Hence, these two lines are equivalent:

  egrep    'pattern|anotherpattern'  *
  grep  -e 'pattern|anotherpattern'  *

Also, the line you ended up with --

  grep -RLi '<%init>' * | grep '.html'

-- should be equivalent to this one --

  grep -RLi '<%init>' *html

-- without needing the second grep statement.

And to weave the multiple pattern matching back in, you can do these:

  egrep -RLi  '<%(init|perl)>' *html
  grep  -RLie '<%(init|perl)>' *html

Both of these should match files that have neither of the two patterns you were asking about: /<%init>/ nor /<%perl>/ .

Make sense?



--
Chris Devers

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to