grep - Patches: patch #6111, Shell script that produces a...
You are not allowed to post comments on this tracker with your current authentication level.
patch #6111: Shell script that produces a pipeline of greps
Submitter: | None | ||
Submitted: | Mon 23 Jul 2007 01:06:42 PM UTC | ||
Category: | None | Priority: | 5 - Normal |
Status: | Wont Do | Privacy: | Public |
Assigned to: | kasal | Originator Email: | -email is unavailable- |
Open/Closed: | Closed |
Mon 23 Jul 2007 01:39:36 PM UTC, comment #1: |
Stepan Kasal <kasal> |
Mon 23 Jul 2007 01:06:42 PM UTC, original submission:
I've written a shell script, pgrep, that accepts combinations of patterns (using logical and/or/not operators) and produces the relevant pipeline of greps. To exemplify,
|
Anonymous |
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Follow 4 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2007-07-23 | kasal | Status | None | Wont Do | |
Assigned to | None | kasal | |||
Open/Closed | Open | Closed | |||
2007-07-23 | None | Attached File | - | Added pgrep, #13440 |
Powered by Savane 3.13-d3ae.
Corresponding source code
Hi,
with the description:
I would interpret "image,picture -gtk,gnome" as
image OR (picture AND NOT gtk) OR gnome
because unary operator usually has the highest priority, and AND usually has higher priority than OR.
And I would expect the script would interpret parentheses as well.
But I think it is more natural to use awk for such a task, instead of several processes. For example, the above example can be implemented with GNU awk this way:
$ apt-cache search view |
gawk 'BEGIN{IGNORECASE=1};
(/image/ || /picture/) && !(/gtk/ || /gnome/)'
As you see, you can use the full power of logical expressions.
Or, if portability to any POSIX-conformant awk implementation were needed:
$ apt-cache search view |
gawk '{l=tolower($0)};
(l~/image/ || l~/picture/) && !(l~/gtk/ || l~/gnome/)'
To conclude, I do not think your script is suitable for inclusion to the GNU grep distribution.
In any case, thank you for your suggestion!
Have a nice day,
Stepan Kasal