in reply to Re^10: Deleting lines from named.conf file
in thread Deleting lines from named.conf file

If you always have your zone definitions separated with blank lines, but no blank lines in the zone blocks, the task is even easier - read and write the file in paragraph mode:
#!/usr/bin/perl -w -ni.bak -00 use strict; BEGIN { local $/ = "\n"; print "please enter the domain name: "; use vars qw($targetdomain); chomp ($targetdomain = <STDIN>); } print unless /^zone\s+"$targetdomain"/;
Call that script with the zone file as argument, e.g.
perl zonedel.pl /home/blackice/hello

It will create a backup of the file. For the switches after '#!/usr/bin/perl' see perlrun.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^12: Deleting lines from named.conf file
by firewall00 (Acolyte) on Nov 14, 2007 at 03:32 UTC
    thanks mr shmem you were surly right but i was having some mistakes . thanks for your great support
Re^12: Deleting lines from named.conf file
by firewall00 (Acolyte) on Nov 12, 2007 at 02:41 UTC

    Really thanks for you further assistance


    but i used what you have said "paragraph mode" but there is also still a 2 blank lines between the zone assume that i have deleted a zone in the middle of 2 zones
    the out is still just like that
    zone "foo.com" { type xxxxx path xxxxx info xxxxx }; zone "blah.com" { type xxxxx path xxxxx info xxxxx }; zone "bar.com" { type xxxxx path xxxxx info xxxxx };
    after running zonedel.pl with your new optimization
    zone "foo.com" { type xxxxx path xxxxx info xxxxx }; #2 blanks still created # zone "bar.com" { type xxxxx path xxxxx info xxxxx };

    i have read perlrun and i didnot find any switch that i can enable to eliminate the the blank lines created
    what do you think about providing a line that makes a shifted up move after delete zone
    or after deletion do
    s/\n//;
    to eliminate the created blank line so i will always have a one blank line between the two zones
    and thanks again for your further support