On Mon, Jul 24, 2000 at 01:26:25PM -0500, Jens B. Jorgensen wrote:
> Frodo Baggins wrote:
>
> > Christian Pernegger scripsit:
> > >Hallo!
> > >
> > >I just stumbled upon the following. If I do
> > >
> > ># cd /
> > ># grep -r * stuff
> > >
> > >it outputs files for maybe half a second then hangs the whole machine. The
> > >last matches were under /dev. I can't remember grep ever scanning device
> > >files, but maybe it's just me...
> > are you shure? shouldn't be
> >
> > # grep -r stuff *
> >
> > ?
> >
> > Anyhow... It will have a problem when grep-ing never endig devices
> > such as /dev/zero.....
>
> Right, so something a little better might be
>
> find / -type f -exec grep stuff {} \; -print
>
> That way you only grep on regular files. You might even want to throw in a -xdev to
> keep from going through /proc.
Just note that xargs can make this more efficient by avoiding exec'ing
"grep" for each file found. For a large 'find' result (eg: recursive
from root), this can be a nontrivial efficiency improvement.
$ find / -type f | xargs grep -l expression
--
Karsten M. Self <kmself@ix.netcom.com> http://www.netcom.com/~kmself
Evangelist, Opensales, Inc. http://www.opensales.org
What part of "Gestalt" don't you understand? Debian GNU/Linux rocks!
http://gestalt-system.sourceforge.net/ K5: http://www.kuro5hin.org
GPG fingerprint: F932 8B25 5FDD 2528 D595 DC61 3847 889F 55F2 B9B0
Attachment:
pgpjLB27WiAQS.pgp
Description: PGP signature