LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   find pattern in any file in directory (http://www.linuxquestions.org/questions/linux-newbie-8/find-pattern-in-any-file-in-directory-511435/)

sancho1980 12-17-2006 06:34 PM

find pattern in any file in directory
 
hi

i know the grep command, which searches for patterns in files
i also tried "grep pattern *", which searches for a pattern in any file in the current directory
but how can i search for a patterin in *any* file within the current directory OR within any subdirectory of the current directory OR within any subdirectory of any subdirectory of the current directory OR...you know what i mean, recursively...
thanx for your hints!
martin

theNbomr 12-17-2006 06:44 PM

find . -exec grep 'YourRegexOrPattern' {} \;

--- rod.

gilead 12-17-2006 07:02 PM

What version of grep are you using? If it supports the recursive (-r) option:
Code:

grep -r 'SomeString' /path/to/search/*

sancho1980 12-19-2006 08:11 AM

Quote:

Originally Posted by theNbomr
find . -exec grep 'YourRegexOrPattern' {} \;

--- rod.

Can you please explain this command to me?

especially the {} \; - part ... i have no idea about shell programming... :-(

thanx,

martin

nx5000 12-19-2006 08:14 AM

man find

its well explained


All times are GMT -5. The time now is 01:18 PM.