The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search two words in sed ajitkumar2 Shell Programming and Scripting 12 08-01-2008 12:00 AM
grep on multiple words to match text template rider29 Shell Programming and Scripting 6 05-23-2008 08:21 AM
problem with grep on search string in a txt file over multiple files m00 UNIX for Dummies Questions & Answers 2 05-18-2008 11:21 AM
grep with find to search for matchiing words akhil313 UNIX for Dummies Questions & Answers 1 12-12-2006 07:18 AM
multiple search with grep amon Shell Programming and Scripting 5 04-04-2006 03:53 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-21-2008
Registered User
 

Join Date: Aug 2008
Posts: 18
Thumbs up search multiple words using grep

Hi frnds

i want to desplay file names that should be word1 and word2

ex :

i have 10 *.log files

5 files having word1 and word2
5 files having only word1,

i have used below command

egrep -l 'word1|word2' *.log

its giving all 10 files, but i want to display only 5 files having both words
Reply With Quote
Forum Sponsor
  #2  
Old 08-21-2008
Registered User
 

Join Date: Aug 2008
Posts: 18
Any one please give a solution.......
Reply With Quote
  #3  
Old 08-22-2008
Registered User
 

Join Date: Aug 2008
Location: India
Posts: 108
grep for "word2" you will get the 5 files.

$ find . -name "*.log" -exec grep -l "word2" {} \;
Reply With Quote
  #4  
Old 08-22-2008
Registered User
 

Join Date: Aug 2008
Posts: 18
i want file names that should be word1 and word2
Reply With Quote
  #5  
Old 08-22-2008
Registered User
 

Join Date: Aug 2008
Location: India
Posts: 108
Thumbs up

did you tried with the command which i given.

It will give you the filename only.
Reply With Quote
  #6  
Old 08-22-2008
Registered User
 

Join Date: Aug 2008
Posts: 18
i have tried but that one given file name having only word2,

but i want filenames that should be word1 and word2....
Reply With Quote
  #7  
Old 08-22-2008
Registered User
 

Join Date: Aug 2008
Posts: 18
i have tried with below statement,its giving a file names but some files having only 6314245093 number i.e its working like or

i am searching for &

find . | egrep -l "379400000000005|6314245093" zisfcon_080820*.log
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0