Need to find a SMALL amount of text in a BIG directory? No problem!
Have you ever tried to grep in a directory that has a vast amount of files and you received an error like this? (below)
![]()
If so, there is a simple way around this. Just use this: find . | xargs grep "yahoo" * | more. I will break down these processes for you:
find .- Find is a command that outputs the location of a file. In this case by specifying a ., the search will only be done in the present directory.xargs- This allows a command to be executed from standard input. This also helps force thegrepcommand (coming next) to return output, even when the directory is too large.grep- The way we will be using this command is to search through a file for a specific string. If you are looking for straight text, it is best to use quotes (e.g. “text”) to help the command line decipher exactly what you are looking for. More info on grep can be found on this earlier post.more- This command is optional for this process. More would be best used if you were expecting a full page of output returned from your search, and want to be prompted for the next page. This option would be very beneficial if the string you are searching for would be common in your results.

June 7th, 2009 at 12:49 am
First let me say this is a handy set of tips on your site.
There is a quicker way to do this as well just by tweaking your find command a bit.
find . -exec grep yahoo {} \;
The exec statement works the same as xargs. You can also narrow down the search results from find using type, name and maxdepth options.
Cheers