#!/usr/bin/perl -w use strict; use File::Find; my %keep; # load %keep with the filenames you want to keep... # $keep{/bin/sh}=1; # $keep{/sbin/ifconfig}=1; # etc.... find(\&checkfile,'/'); sub checkfile{ my $fname="$File::Find::dir/$_"; if(!defined $keep{$fname}){ print "deleting $fname\n"; # unlink $fname; } }