Thank you Dimitar Radoulov for your help!
How can I re-write the same to print only the lines which has the matching
string, and just the 4th line before that and sixth line after that?
Thanks in advance
Ansu
----- Original Message -----
From: Dimitar Radoulov <[EMAIL PROTECTED]>
Date: Sunday, February 17, 2008 3:54 pm
Subject: Re: [Solaris-Users] Print lines above and below ....
> On Feb 17, 2008 1:13 PM, Radoulov, Dimitre <[EMAIL PROTECTED]>
> wrote:> [EMAIL PROTECTED] wrote:
> > [...]
> > > I want to print a line which contain a string with 4 lines
> above 6 lines below to an output file. Here is the example:
> > [...]
> > awk '{ x[FNR] = $0 }
> > f && f--
> > /dock/ { for (i=FNR-4; i<=FNR; i++)
> > print x[i]
> > split("",x)
> > f = 6 }' filename
>
> Just to add that you should use nawk or /usr/xpg4/bin/awk
> with this code.
>
> Another version
> (works with /usr/xpg4/bin/awk and GNU Awk):
>
> awk '{ x[FNR] = $0 }
> /doc/ {
> min = FNR - 4
> max = FNR + 6
> }
> FNR == max {
> for (i=min; i<=max; i++)
> print x[i]
> delete x
> }' filename
> _______________________________________________
> Solaris-Users mailing list
> [email protected]
> http://www.filibeto.org/mailman/listinfo/solaris-users
>
_______________________________________________
Solaris-Users mailing list
[email protected]
http://www.filibeto.org/mailman/listinfo/solaris-users