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
grep command christine33990 UNIX for Dummies Questions & Answers 11 05-05-2008 11:45 PM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-04-2007 11:59 PM
grep command help ishmael^soyuz Shell Programming and Scripting 4 07-11-2007 06:01 AM
grep command pmsuper UNIX for Dummies Questions & Answers 6 11-22-2006 04:12 AM
grep command debasis.mishra Shell Programming and Scripting 1 03-27-2006 10:53 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 04-12-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Code:
 grep -A 2 'ERROR' file
Reply With Quote
Forum Sponsor
  #9  
Old 04-12-2007
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,590
Quote:
Originally Posted by ghostdog74
Code:
 grep -A 2 'ERROR' file
That won't work with a standard grep, it is a gnu'ism
Reply With Quote
  #10  
Old 04-12-2007
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,248
Try...
Code:
awk '/ERROR/{c=3};c-->0' file
Reply With Quote
  #11  
Old 04-12-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
sed -n "/^ERROR/{N;N;N;p;}" file
Reply With Quote
  #12  
Old 04-13-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Anbu23,
Great solution!
There is only one minor issue that it is very easy to resolve.
It is displaying four lines, instead of 3 including the "ERROR" line per Geekeezoid specs.
Reply With Quote
  #13  
Old 04-13-2007
Registered User
 

Join Date: Apr 2007
Posts: 6
Thanks for all the replies and suggestions.. will try all of them when i have some free time today... thanks again
Reply With Quote
  #14  
Old 04-13-2007
Registered User
 

Join Date: Apr 2007
Posts: 6
Quote:
Originally Posted by anbu23
Code:
sed -n "/^ERROR/{N;N;N;p;}" file

This worked... thanks... yes there was only a minor issue.. but it definitely did its job... thanks alot guys...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:48 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