Delete only the nth block of text, multi-line

"Lars Noodén [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Using GNU sed 4.2.2-4ubuntu1 on Ubuntu 14.04 LTS GNU/Linux


I have some blocks of text spread over multiple lines and delimited by [
and ].  ( See the tail of the message for an example. )  I'd like to
delete the nth [ ] block.  The following pattern will delete all [ ] blocks:


 sed '/^\[$/,/^\]/d' in > out


That deletes more than I want deleted.  How can I make a sed formula or
two that only deletes the nth block and leaves the others?


Regards,
/Lars


###


foo
[
  aaa
  bbb
  ccc
]
[
  ccc
  bbb
  aaa
]
[
  bbb
  ccc
  aaa
]
[
  bbb
  aaa
  ccc
]
bar


###
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.