URL:
  <http://savannah.gnu.org/bugs/?22100>

                 Summary: Enhancement request: "grep foo | grep bar" in one
process  (i.e. line-selector and pattern selector)
                 Project: grep
            Submitted by: richardneill
            Submitted on: Thursday 24/01/08 at 04:45
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I frequently find myself writing a construct of the type:
  grep LINE_MATCH filename | grep -oE WORD_MATCH

For example, consider a data file:

  apples: 12
  oranges: 15
  bananas: 20

How many oranges do I have?

  grep oranges fruit.txt | grep -oE [0-9]+

results in "15".

But I had to run 2 instances of the grep command, which is inefficient. (This
is noticeable even for small files, even on a fast machine).  

So my proposal is to have some extra options to grep, eg:
  grep --line oranges --pattern -oE [0-9]+  fruit.txt

Alternatively, what about allowing multiple instances of -E, or supporting
--first --second --third ?

Thanks very much,

Richard





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?22100>

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



Reply via email to