Re: Delete only the nth block of text, multi-line

"Davide Brini [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 26 Feb 2015 09:09:49 -0800, "[email protected] [sed-users]"
<[email protected]> wrote:

> I made one minor change (added \n to the regular expression) to Davide's
> solution, to make the script get rid of an extra line that was showing up
> in the output. This assumes you are using GNU sed, other sed versions
> might not recognize \n in the regular expression. 

That fails if the block being removed is the last one and there are no
further lines in the file, so at least you should make it optional:

s/\[[^]]*\]\n\{0,1\}//3

On the other hand, if we can assume an input like the one given as sample,
there will always be something after the last block so the \n can stay
without changes.

-- 
D.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.