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

Re: Finding files containing 'string'



On Thursday, Feb 2nd 2006 at 09:50 -0800, quoth Rick Stevens:

=>To search ALL files, display the files with matching names AND the line
=>that matches:
=>
=>	# find / -exec grep -iH pattern \{\} \;
=>
=>Modify the find command to exclude directories you know you aren't
=>interested in.  For example to ignore any "mail" directories:
=>
=>	# find / -path "*mail*" -prune -o -exec grep -iH pattern \{\} \;

GGAAAAAHH!

find dir -type f | xargs grep stuff

Learn it. Love it. The Bad Way will generate a child process to search one 
file. The Good Way will generate the minimal number of grep processes to 
do the job. Also note the use of -type f so you don't seaarch devices and 
directories.

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


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