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