If it's not too late -- I just found this thread -- or too heretical
, would not the following do what you want?:
Code:
#! /bin/bash
F="bind"
read -p " please enter the domain name: " X
sed -i '\#^zone .*'$X'#,\#^}#s,^,//,;\#//}#N;s,\n *,\n//,' $F
I named my test file bind & put your "hello" contents in it followed by 2 blank lines, here is the output of my little script:
Quote:
//zone "mydomain.com" {
//type master;
//file "/path/to/zone/mydomain.com";
//notify yes;
//}
//
|
I think that's the same as your last post.
If my
sed seems cryptic, it might help to know that I am using '#' as the delimiter for the address regexes & ',' as the delimiter for the replace regexes. Although I rarely see it, I believe Perl also has this feature.
If you were to use this, you might want to eliminate the "-i" (in-line) option & send the output to a different file instead, at least during testing.