Delete blocks of lines from text file

Hello,

Hello Firends,
I have file like below. I want to remove selected blocks say abc,pqr,lst. how can i remove those blocks from file.

zone abc {
blah
blah
blah }

zone xyz {
blah
blah
blah }

zone pqr {
blah
blah
blah }

zone lst {
blah
blah
blah }

zone bzs {
blah
blah
blah }

if your sed has the -i option:

sed  -i  '/zone pqr/,/}/d' newfile

Thanks Yogesh
I have almost 3000 blocks in this file. I have another list file which contain list of zone names e.g. pqr,abc,bzs.
I am using awk to run your sed command for each zone in list file

{
   zonename = $1
   sedcmd = "sed '/" zone zonename "/,/}/d' named.backup > named.backup.test"
   printf "Command: %s\n", sedcmd
   system(sedcmd)
   system("mv named.backup.test named.backup")
}

I think it's possible to optimize above coding. It's possible to remove system("mv named.backup.test named.backup") with some change.
Could you please help me for it

have you checked if -i option is supported in your sed?

Hi,
Please try follow one.

One concern, i am not sure what will be content of all your blah blah. If they will cover all the content, maybe will cause some conflict with the code. Anyway, please try it, if any problem, please post it. Maybe all of us here can help you to solve it.

code:

sed '/^$/d' a > a.tmp
nawk 'BEGIN{
FS="\r"
RS="}\r"
a="abc"
b="pqr"
}
{
if ($1=="" && index($2,a)==0 && index($2,b)==0)
	print $0
if ($1!="" && index($1,a)==0 && index($1,b)==0)
	print $0
}' a.tmp
rm a.tmp