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 > 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
SED Search Pattern and Replace with the Pattern racbern Shell Programming and Scripting 4 03-15-2008 05:59 AM
Search for a pattern DNAx86 Shell Programming and Scripting 26 03-12-2008 07:03 AM
pattern search ali560045 Shell Programming and Scripting 2 11-28-2007 08:04 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 03:41 PM
how to search the pattern vasikaran UNIX for Dummies Questions & Answers 2 06-30-2005 04:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-05-2007
boopathi_d boopathi_d is offline
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.
  #2 (permalink)  
Old 12-05-2007
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

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

Code:
grep '05-Dec' filename.ext|grep 'Exception'
  #3 (permalink)  
Old 12-05-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Code:
awk '/05-Dec/ && /Exception/{print}' file
  #4 (permalink)  
Old 12-05-2007
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
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
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 11:43 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