LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   giving search-string(s) from a file to linux "find" command (https://www.linuxquestions.org/questions/linux-newbie-8/giving-search-string-s-from-a-file-to-linux-find-command-471470/)

Fond_of_Opensource 08-07-2006 01:23 AM

giving search-string(s) from a file to linux "find" command
 
I want to use the Linux command find to find pattern from a file. (i.e. the search criteria/pattern string(s) are stored in file and the file's content is given as input to the find command. The file will contain the search strings. How to perform this task using find command???

titopoquito 08-07-2006 05:03 AM

I don't know if I understand you exactly. But what I understand would differ depending on the count of patterns (lines) in the file you use for the pattern(s).
I will show it with a simple search for the pattern(s) as filename in the actual folder.

One argument/line:
Code:

find . -name "`cat name-of-pattern-file`"
Severeal arguments in several lines:
Code:

cat name-of-pattern-file | while read pattern; do find . -name "$pattern"; done

skuletm 02-02-2009 02:49 PM

finding a string within some file using linux find
 
Quote:

Originally Posted by Fond_of_Opensource (Post 2368944)
I want to use the Linux command find to find pattern from a file. (i.e. the search criteria/pattern string(s) are stored in file and the file's content is given as input to the find command. The file will contain the search strings. How to perform this task using find command???

I believe you need to simply find a certain string within some file?
if so, you can use the following:
find . | xargs grep 'string'

Cheers!

chrism01 02-02-2009 07:14 PM

recursive grep ?
Code:

for pattern in `cat strings.dat`
do
    grep -r $pattern * >> found.txt
done



All times are GMT -5. The time now is 07:16 PM.