LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-04-2007, 11:37 AM   #1
walterbyrd
Member
 
Registered: Apr 2004
Posts: 734

Rep: Reputation: 46
can not get "grep -f" to work with RHEL 4.x


I am embarassed to post such a simple question, but this is driving me nuts. The "grep -f" command just does not seem to work.

I am absolutely positive that the string exists in one of the files in the list. I have tried every combination I can imagine:

Note:
file_with_string.txt = a file with a single string
list_of_files_to_search.txt = a file which lists other files in the directory

I have tried all of the following:

grep -f file_with_string.txt list_of_files_to_search.txt

grep -f list_of_files_to_search.txt file_with_string.txt

grep file_with_string.txt -f list_of_files_to_search.txt

grep 'string' -f list_of_files_to_search.txt

grep -f list_of_files_to_search.txt 'string'

grep -f 'string' list_of_files_to_search.txt

and so on. I have also tried egrep. I can not get anything to work.
 
Old 04-04-2007, 01:53 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
-f references a file of strings to grep for. it has nothing to do with referencing a file for a list of files to search in. so in your first example, which is about the closest, the content of the file "list_of_files_to_search.txt" would itself be the data to be grepped.
 
Old 04-05-2007, 08:56 PM   #3
walterbyrd
Member
 
Registered: Apr 2004
Posts: 734

Original Poster
Rep: Reputation: 46
D'Oh. Thank you.

Do you know if there is a way to give grep a list of files? Other than pattern matching?
 
  


Reply



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
"dig mx" and "ping google" do not work when bind9 runs.. why? alexxxis Linux - Software 4 01-07-2007 03:16 AM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 01:34 PM
"<" ">" Keyboard keys on Toshiba Satellite 1005-s157 dont work RodCas Linux - Laptop and Netbook 1 05-08-2004 04:22 PM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 03:11 PM
<input type="button" disabled="true" > does not work in ns4.7 or 4.9 cybercop12us Programming 2 11-29-2002 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration