bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #15280] Feature request: better support for multiple patterns


From: Ed Avis
Subject: [bug #15280] Feature request: better support for multiple patterns
Date: Fri, 23 Dec 2005 11:01:56 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5

URL:
  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=15280>

                 Summary: Feature request: better support for multiple
patterns
                 Project: grep
            Submitted by: epaepa
            Submitted on: Fri 12/23/05 at 11:01
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open

    _______________________________________________________

Details:

Grep lets you specify more than one pattern using multiple -e options.  Then
a line matches if any of the patterns match.  Effectively each -e means
'or'.

It would be useful to have -and and -not options a la find(1), so 

% grep -e hello -and -e there

to match lines containing both words.  This simple example could be done with
two grep processes in a pipeline, but it's certainly faster to grep the file
once, and once you start adding context:

% grep --context=10 -e hello -and -e there

it's not really possible to get the same search with two separate greps.

The -v flag negates the sense of matching but it applies globally.  You
cannot ask grep to print lines matching one pattern but not another.  As far
as I know, grep's regular expressions don't have a negation operator so this
would be an increase in grep's power.  And handy together with -and, for
example

% grep --context=10 -e '\*\*\*' -and -not -e 'modification time'

as a way to search your build logs for make errors which aren't the common
'modification time in the future'.






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=15280>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]