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
single line input to multiple line output with sed mitch Shell Programming and Scripting 8 07-16-2008 10:57 AM
reading ps command's output line by line s. murat Shell Programming and Scripting 5 05-22-2008 01:23 AM
How to grep / zgrep to output ONLY the matching filename and line number? vvaidyan UNIX for Dummies Questions & Answers 3 03-12-2008 01:33 PM
Multi-line output to single line LinuxRacr Shell Programming and Scripting 7 02-26-2008 06:05 AM
need grep to output basename and line# zoo591 Shell Programming and Scripting 18 07-16-2005 07:34 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-23-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
Stumble this Post!
Grep or other ways to output line above and/or below searched line

Hi all,

Would like to know how I could search for a string 'xyz' but have the output show the line plus the line above and/or below all lines found.

eg. search for xyz from file containing:

abc
12345
asdf xyz asdfds
wwwww
kjkjkj
ppppp
kkkxyz
eeee
zzzzz

and the output to show:

12345
asdf xyz asdfds
wwwww
ppppp
kkkxyz
eeee

option to only show line above or below or x number of lines above or below.

preference to use script rather than something like perl...

thanks...
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-23-2008
Registered User
 

Join Date: Jul 2008
Location: Texas
Posts: 59
Stumble this Post!
Refer to this recent thread: how to get surrounding lines of grep result
Reply With Quote
  #3 (permalink)  
Old 07-23-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
Stumble this Post!
Cool !!
sorry couldn't find it earlier.
cheers
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0