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

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AWK: Multiple patterns per line Plavixo UNIX for Dummies Questions & Answers 1 05-05-2008 04:31 PM
How to get lines in between Patterns? racbern Shell Programming and Scripting 11 04-23-2008 07:28 AM
Perl: Match a line with multiple search patterns Juha Shell Programming and Scripting 10 04-09-2008 01:43 AM
get the value between 2 patterns minifish Shell Programming and Scripting 11 04-07-2008 02:18 PM
searching for two or more patterns in a line metalwarrior UNIX for Dummies Questions & Answers 4 02-05-2008 01:01 AM

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 02-16-2008
bashuser bashuser is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 3
3 patterns in one line

hello, I want to write a script to find all the files that contain 3 specific patterns. example: shows the files containing any line that contain pattern1, pattern2 and pattern3, but the patterns can be in any order as long as they exist in the line.
can I do that with grep?
thank you
  #2 (permalink)  
Old 02-16-2008
cadanir cadanir is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 7
Under any Unix or Linux, to find...:
- by searching from /your_start_dir directory
- all files with .txt extension
- also by following symbolic links, if any
- for each such file, execute a regular expression search with :
- _Extended grep
- _list only file names (without -l, will also print found lines)
- do the search case _insensitive
- search pattern pat1 or pat2 or pat3
type this command:
find /your_start_dir -name '*.txt' -follow -exec grep -E -l -i 'pat1|pat2|pat3' {} \;
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 12:19 PM.


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