#!/usr/bin/perl -l # guess what, this stinks re: RAM use strict; use warnings; use File::Find; use Getopt::Long; our @SEARCH_DIRS = (); our $SHOW_LINK = 0; GetOptions ( "dir=s" => \@SEARCH_DIRS, "links" => \$SHOW_LINK, ); @SEARCH_DIRS=('/') unless @SEARCH_DIRS; my @dirs_not_to_search = qw(^/dev lost+found ^/mnt ^/proc ^/tmp); my $nosearch_regex = join '|', @dirs_not_to_search; my %rpm_files; open(RPM_FILES, "rpm -qal |") or die "can't read from rpm\n"; while() { chomp; $rpm_files{$_}++; } find( \&search, @SEARCH_DIRS); sub search { if ( -d and $File::Find::name =~ /$nosearch_regex/o) { $File::Find::prune=1; return; } elsif ( -l ) { print $File::Find::name if $SHOW_LINK; } elsif ( -f ) { print $File::Find::name unless defined $rpm_files{$File::Find::name}; } }