using sed(?) to delete a block of text

hello people,
i am trying to accomplish what i thought should be a simple task: find a token in a file and delete a number (let's say 25) of lines following the token.

in sed, i can't figure out how to do a relative address (i.e. something like /token/25dd to delete 25 lines) and in gnu grep, if i use the -A 25 option, it only works with a positive match, but not with -v

i suppose i could accomplish same by matching the number of open and closed parentheses (), since that's how the file is formatted, but i'm also not sure how to do that :frowning:

any thoughts would be most welcome!

thanks in advance

ilya

P.S. for example

if the file contains:

a: (
some text(more)
blah (blah)
)

b: (
another(word)
and stuff(gf)
)

===========

i would want to remove the 4 lines from a: to )

GNU sed supports this.

from the manual page

So....

sed '/^a:/,+3 d' filename

should do what you want.

Cheers
ZB

Using awk...

awk '/^a:/{c=4};--c<0' file

thank you, thank you zazzybob and ygor!

In defence of my lack of RTFM: MANPATH on my solaris box! i got the solaris sed manpage, rather than the gnu one :slight_smile: