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
help on egrep arund_01 Shell Programming and Scripting 2 05-13-2008 10:26 AM
egrep help Darklight Shell Programming and Scripting 1 04-17-2008 11:34 PM
egrep DNAx86 Shell Programming and Scripting 7 01-18-2008 04:59 AM
Egrep cheat sheet anywhere? Looking for meaning of egrep -c leelm UNIX for Dummies Questions & Answers 2 01-11-2008 11:37 AM
egrep help Vozx Shell Programming and Scripting 2 12-09-2005 06:42 AM

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

Join Date: Jul 2006
Posts: 4
help with egrep

I have a file called alert.log containing the following:

WARNING: received KRVX_OPER_CANNOT_SUPPORT
knlldmm: gdbnm=CROOP
knlldmm: objn=23793
knlldmm: objv=1
knlldmm: scn=5189816456
knllgobjinfo: MISSING Streams multi-version data dictionary!!!
knlldmm: gdbnm=FDROP
knlldmm: objn=49385
knlldmm: objv=2
knlldmm: scn=5201332536


Is there any way I can use egrep to pull out only lines 6-10 out of the file? I tried using:

egrep -n -i "knllgobjinfo|knlldmm" alert.log

but that also gives me lines 2-5 which I dont want.
If egrep can't do it, what else can I use that can?

Thanks in advance.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-01-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,861
Code:
sed -n '6,10p' alert.log
You can also use regex ranges:
Code:
sed -n '/knllgobjinfo/,/$/p' alert.log
Reply With Quote
  #3 (permalink)  
Old 08-01-2006
Dhruva's Avatar
Registered User
 

Join Date: Mar 2006
Location: India
Posts: 255
hi jim.First command is printing 6-10 but the second one is printing only 6-7 lines.

Code:
sed -n '/knllgobjinfo/,/$/p' alert.log
Reply With Quote
  #4 (permalink)  
Old 08-01-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,861
typo, my bad.:
(this assumes there is a \n on the end of the last line)
Code:
sed -n '/knllgobjinfo/,$p' alert.log
Reply With Quote
  #5 (permalink)  
Old 08-01-2006
Registered User
 

Join Date: Jul 2006
Posts: 4
Thanks a lot, you answered my question, but its not exactly what I was looking, I wasn't as specific as I should have been.

What I really meant is: How can I print to standard output the line beginning with "knllgobjinfo" and its following 4 lines, regardless of where it occurs in the file.

Thanks again.
Reply With Quote
  #6 (permalink)  
Old 08-01-2006
Registered User
 

Join Date: Jan 2006
Posts: 43
Dude try following.

sed -n -e '/knllgobjinfo/,+4 p' datafile

Cheers,
Nilesh
Reply With Quote
  #7 (permalink)  
Old 08-01-2006
Registered User
 

Join Date: Jul 2006
Posts: 4
nope, this is the error that I get.

sed: 0602-404 Function /knllgobjinfo/,+4 p cannot be parsed.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:02 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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0