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
make multiple line containing a pattern into single line VTAWKVT Shell Programming and Scripting 13 12-04-2008 06:40 PM
reading line by line and grepping QueryMaster Shell Programming and Scripting 4 01-30-2008 05:12 PM
add a line after a pattern melanie_pfefer Shell Programming and Scripting 2 05-07-2007 01:38 PM
sed - Replace Line which contains the Pattern match with a new line kousikan Shell Programming and Scripting 2 03-24-2007 07:24 AM
grepping for something but excluding something else in the line fusion99 UNIX for Dummies Questions & Answers 1 09-28-2004 03:05 PM

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 10-05-2007
iAm4Free iAm4Free is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 18
Grepping 1 line above and below pattern

I have a pattern::

xldn3176bap>arj SOCRATES_MAIN_LNX | grep " FA "
10/04/2007 21:01 10/04/2007 21:01 FA 1776752/1 1

I want the line above this line and the line below it too. Can anyone tell me how it can be done?

- iAm4Free
  #2 (permalink)  
Old 10-05-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
The GNU version of grep has the "-C" option (context) that does exactly what you need.
  #3 (permalink)  
Old 10-05-2007
iAm4Free iAm4Free is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 18
Quote:
Originally Posted by cbkihong View Post
The GNU version of grep has the "-C" option (context) that does exactly what you need.
It didn't work for me
  #4 (permalink)  
Old 10-05-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
http://www.unix.com/302098992-post2.html
  #5 (permalink)  
Old 10-07-2007
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
awk

sorry,

i reply to the wrong thread, and do not know how to delete.
Sponsored Links
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 07:46 AM.


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