[techtalk] Limits of grep?

Andrew Wendt awendt at putergeek.com
Wed Sep 27 08:41:17 EST 2000


>> find . -type f -print | xargs grep <pattern> /dev/null

I don't get it. I doubt it hurts, but why the /dev/null?

>I have a similar problem to Subba's but with an additional twist. It's
>this directory with at worst ~50000 text files that are all called
>some number.letter, for example 1056.a or 5785.l. I usually need to
>grep only in f ex *.l or *.a. Is there any way to accomplish this? For
>now I've just done a ls < xargs grep foo, because it seems to be
>faster than find and there aren't any binary files, but it's kind of
>silly to grep in everything when it's really just the results from *.l
>I want.

Find has a -name option you can use:
find . -type f -name "*.o" -print

Or you could just grep the output of find, if you wanna use a regexp:
find . -type f -print | grep "[.]o$"

TTFN
Andy




More information about the Techtalk mailing list