The following first captures the file names in named.conf and places them into a hash. It then globs the zonefiles' directory, and attempts to find each listed file from that directory in the hash. If the file name's not in the hash, it's pushed onto @unlistedFiles for later processing:
use strict; use warnings; my ( %named_conf, @unlistedFiles ); open my $fh, '<', 'named.conf' or die $!; /\s+file\s+"([^"]+)/ and $named_conf{$1}++ for <$fh>; close $fh; chdir 'zonefiles' or die $!; !defined $named_conf{$_} and push @unlistedFiles, $_ for <db.*>; print "$_\n" for @unlistedFiles;
Files in zonefiles directory:
db.127.0.0 db.brian.com db.cache db.test.com db.what db.why
Output using your named.conf:
db.what db.why
Hope this helps!
In reply to Re: Compare zone files in directory with what is listed in named.conf
by Kenosis
in thread Compare zone files in directory with what is listed in named.conf
by brianjb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |