The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SED Search Pattern and Replace with the Pattern racbern Shell Programming and Scripting 4 03-15-2008 02:59 AM
Search for a pattern DNAx86 Shell Programming and Scripting 26 03-12-2008 04:03 AM
pattern search ali560045 Shell Programming and Scripting 2 11-28-2007 05:04 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 12:41 PM
how to search the pattern vasikaran UNIX for Dummies Questions & Answers 2 06-30-2005 01:34 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-05-2007
Registered User
 

Join Date: Nov 2007
Posts: 1
Search for a pattern from the result of search

I want to search for a pattern in a file based on the result of search. For example,

grep '05-Dec' filename.ext

For searching 'Exception' pattern, I used,

grep 'Exception' filename.ext

Anyway, these two worked successfully when run individually. But I want to search the second pattern based on the result of the first pattern.

Please help me out.
Reply With Quote
Forum Sponsor
  #2  
Old 12-05-2007
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
U have to understand the use of pipes:

Code:
grep '05-Dec' filename.ext|grep 'Exception'
Reply With Quote
  #3  
Old 12-05-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Code:
awk '/05-Dec/ && /Exception/{print}' file
Reply With Quote
  #4  
Old 12-05-2007
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
Quote:
Originally Posted by ghostdog74 View Post
Code:
awk '/05-Dec/ && /Exception/{print}' file
That“s better, just a minor thing u can drop print :
Code:
awk '/05-Dec/ && /Exception/' file
Regards
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 07:11 AM.


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