The UNIX and Linux Forums  
Hello and Welcome from to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Ignore some lines with specific words from file comparison jakSun8 Shell Programming and Scripting 2 03-13-2008 12:11 AM
Search File for Specific Words mevasquez UNIX for Dummies Questions & Answers 2 12-04-2007 04:31 PM
Tar Exclude Dir with a Specific Words rhartleyoh UNIX for Dummies Questions & Answers 1 07-26-2007 11:53 AM
How to search files containing a specific word in the content amjath78 UNIX for Dummies Questions & Answers 1 01-03-2007 03:42 PM
Search all files for specific string sureshy UNIX for Dummies Questions & Answers 4 03-06-2002 12:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-21-2007
WoodenSword WoodenSword is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 7
Search files that all contain 4 specific words

Hello,

I want an one line command that brings me back all the files in a folder that contain 4 specific words anywhere inside them.

I want to use find,xargs and grep. for example i know for one word the command would be:

find . | xargs grep 'Word1'

But i don't know for 4 specific words what i should do.

Thanx
  #2 (permalink)  
Old 01-21-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,538
you can use egrep "word1|word2|word3|word4"
  #3 (permalink)  
Old 01-21-2007
WoodenSword WoodenSword is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 7
thank you,
but i don't think that this is what i want.this will give me and the files that only contain word1 and not word2 and word3 and word4.

I want the files returned to contain all 4 words
  #4 (permalink)  
Old 01-21-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Try...
Code:
find . -type f | xargs perl -0 -n -e 'print $ARGV."\n" if /word1/&&/word2/&&/word3/&&/word4/'
  #5 (permalink)  
Old 01-22-2007
WoodenSword WoodenSword is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 7
Well thank you very much,

but i don't want to use the command perl. I want to use the commands find,xargs and grep. Is it possible??
  #6 (permalink)  
Old 01-22-2007
Krrishv Krrishv is offline
Registered User
  
 

Join Date: Dec 2006
Location: CA,United States
Posts: 186
try egrep

find . | xargs egrep "word1|word2|word3"
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0