[b0b0b6]: rm_cisco_dups Maximize Restore History

Download this file

rm_cisco_dups    33 lines (26 with data), 772 Bytes

#!/usr/bin/perl -w
# rm_cisco_dups - look for duplicate mibs in cisco land

my $file = shift || 'mib_index.txt';
my $dir  = shift || 'cisco';

die "Usage: $0 mib_index.txt cisco\n  Will kill dups in cisco dir." unless (-r $file and -d $dir);

open (FILE,"<$file") or die "can't open file : $file. $!\n";

while (<FILE>){
    chomp;
    if ($_ =~ /^(.*)\s+(.*)$/){
        my $mib = $1; my $file = $2;
        push @{$MIBS{$mib}},$file;
    }
}

print "Found ", scalar keys %MIBS, " mibs.\n";

MIB:
foreach my $mib (keys %MIBS){
    next unless scalar(@{$MIBS{$mib}} > 1);
    print "$mib : ";
    foreach my $f (@{$MIBS{$mib}}) {
        if (unlink("$dir/$f")){
            print " removed.\n";
            next MIB;
        }
    }
    print " not found in cisco/.\n";
}