LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-07-2006, 12:23 AM   #1
Fond_of_Opensource
Member
 
Registered: May 2006
Posts: 55

Rep: Reputation: 15
Unhappy 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???
 
Old 08-07-2006, 04:03 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Ruhr Area, Germany
Distribution: Slackware64 14.0
Posts: 1,524

Rep: Reputation: 94
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

Last edited by titopoquito; 08-07-2006 at 04:04 AM.
 
Old 02-02-2009, 01:49 PM   #3
skuletm
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Rep: Reputation: 0
Lightbulb finding a string within some file using linux find

Quote:
Originally Posted by Fond_of_Opensource View Post
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!
 
Old 02-02-2009, 06:14 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
recursive grep ?
Code:
for pattern in `cat strings.dat`
do
    grep -r $pattern * >> found.txt
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to tell "find" to not search inside hidden folders? robo555 Linux - General 8 08-08-2011 06:30 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
vim search string question with /" and \" m_lp_ql_m Programming 2 08-03-2006 12:48 AM
using java to find the location of the "\" char in a string caged Programming 8 02-03-2004 10:42 AM


All times are GMT -5. The time now is 10:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration