We have a rather large and complex file system and I am trying to generate a list of files containing a particular text string. This should be simple, but I need to exclude the './svn' and './pdv' directories (and probably others) and to only look at files of type *.p, *.w or .i.
I can easily do this with a program, but it is proving very slow to run. I want to speed up the process (so that I'm not searching thousands of files repeatedly) as I need to run such searches against a long list of criteria.
Normally, we search the file system using:
find . -name "*.[!r]*" -exec grep -i -l "search for me" {} \; This is working, but I'm then having to use a program to exclude the unwanted directories , so it is running very slowly.
After looking at the topics here: Stack Overflow thread
I've decided to try a few other aproaches:
grep -ilR "search for me" . --exclude ".svn" --excluse "pdv" --exclude "!.{p,w,i*}" Excludes the './svn', but not the './pdv' directories, Doesn't limit the files looked at.
grep -ilR "search for me" . --exclude ".svn" --excluse "pdv" --include "*.p" Excludes the './svn', but not the './pdv' directories, Doesn't limit the files looked at.
find . -name "*.[!r]*" -exec grep -i -l ".svn" | grep -i -l "search for me" {} \; I can't even get this (or variations on it) to run successfully.
find . ! -name "*.svn*" -prune -print -exec grep -i -l "search for me" {} \; Doesn't return anything. It looks like it stops as soon as it finds the .svn directory.
--excluse "pdv"(note the typo s/d) in both cases and you are complaining about that particular condition not working... just checking typo is not the main problem.grep -ilR "run" . --exclude ".svn" --exclude "pdv" --exclude "!.{p,w,i*}". Unfortunately as the results set now includes both.svn/text-base/jr83144.p.svn-baseandpdv/cm/backupds.iI don't think that this has worked. Many thanks--exclude-dirparameter? That is actually the problem I think. Refer to the manual ofgrep.