bug-grep
[Top][All Lists]
Advanced

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

Re: [bug-grep] avoiding non-plain files with -I (p,b,c)


From: Bob Proulx
Subject: Re: [bug-grep] avoiding non-plain files with -I (p,b,c)
Date: Thu, 21 Apr 2005 22:00:19 -0600
User-agent: Mutt/1.5.9i

Jacob Lerner wrote:
> When I'm grepping recursively starting from /etc or from /,
> I often observe 'grep -r -I' stuck. This happens when there is FIFO node
> under /etc. I believe grep is stuck trying to open FIFO "files". 
> (Might be also stuck opening device files (b/c nodes), I'm not sure.)
> 
> Does grep have a option to ignore all non-plainfiles (
> FIFOs(p), devices (b,c)) ? WHat if -I option can be aliased to ignore
> non-plainfiles ?

Yes, I know that grep has a --recusive option and some others.  But I
think that was a bad idea.  I recommend that you avoid them.  Better
to use find|xargs for a powerful combination that works with most of
the rest of the available tools on the system.

> My workaround is ugly, I do something like 'find /etc -type f | grep+ regex'
> where grep+ is a script which reads filenames from stdin and greps them.
> This is slow, though, but does avoid being stuck on non-plainfiles.

I don't know what is in grep+ to make it slow.  But the following
should be a fast solution.

  find /etc -type f -print0 | xargs -r0 grep -H PATTERN

Bob




reply via email to

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