Script to delete zone from named.conf

Mark Andrews marka at isc.org
Thu Feb 4 22:16:03 UTC 2010


In message <20100204212727.GA23141 at norchemlab.com>, Justin T Pryzby writes:
> On Thu, Feb 04, 2010 at 06:19:07PM +0000, Evan Hunt wrote:
> > > I know I can do that with grep, but you see I have 270 domains to delete
> > > from my named.conf. 
> > > 
> > > My question was more: has anyone got a working script that I can use in
> > > order to delete name from my "named.conf" file ? 
> > 
> > cat named.conf | \
> >     awk 'BEGIN {suppress = 0}
> >          /zone "whatever.com"/ {suppress = 1}
> >          {if (suppress == 0) print; if ($1 == "};" && NF == 1) suppress = 0}'
> > 
> > Or words to that effect.  Works as long as the zones are always formatted
> > the same way.
> As an alternative:
> 
> To remove the "toxtracker.info" zone:
> awk -v s=toxtracker.info 'BEGIN{RS=""; s="zone \""s"\""} $0~s{print $0"\n"}'
> 
> Justin
> _______________________________________________
> bind-users mailing list
> bind-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users

Recent version of named-checkconf have a -p (print) option which
will emit named.conf, sans comments, in a consistent style which
will then be easy to post process.
-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: marka at isc.org



More information about the bind-users mailing list