I'm using ShellScript to edit my bind dns configuration file, when add and remove zone references. Then in "master.conf" file we have this content:
...
...
zone "mydomain.com" {
type master;
file "/var/zones/m/mydomain.com"
};
...
...
I want "remove" this entry to "mydomain.com" using "sed", but I could'n write a correct regex to this. The expression must use variable domain name and search until next close bracket and semicolon, something like this:
DOMAIN_NAME="mydomain.com"
sed -i.bak -r 's/^zone "'$DOMAIN_NAME'" \{(.*)\};$//g' /var/zones/master.conf
See that we should ignore the content between brackets, and this chunk have to replaced with "nothing". I tried some variations of this expression, but without success.