Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

excluding/including directories in grep search path

0 views
Skip to first unread message

Daliyot, Maoz

unread,
Dec 3, 2009, 3:39:31 AM12/3/09
to bug-gn...@gnu.org, Daliyot, Maoz
Hello,
How can I exclude/include directories in grep's search list?

In my grep version, exclude/include switches only apply to files:

--include=PATTERN
Recurse in directories only searching file matching PATTERN.

--exclude=PATTERN
Recurse in directories skip file matching PATTERN.


Thanks.

Maoz

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Bob Proulx

unread,
Dec 3, 2009, 5:11:01 PM12/3/09
to Daliyot, Maoz, bug-gn...@gnu.org
Daliyot, Maoz wrote:
> How can I exclude/include directories in grep's search list?

The Unix philosophy would be to use programs that do one thing well.
In this case 'find' is IMNHO the better model. The 'find' command is
specifically designed to traverse directory hierarchies in whatever
way that you want and to interface to other utilities easily.

find . -name FOODIR -prune -o -type f -exec grep PATTERN {} +

Bob


0 new messages