#!usr/bin/perl # Author: Ryan Scadlock # Date: 6 July 2002 use strict; my $path = './'; die "The file $base_file does not exist!\n" if (!-f $base_file); # Initiate the recursion &RecurseDirs($path); rm temp; print "The result can be found at Results file in this dir"; #### SUBROUTINES SECTION #### # Function that recurses through the directory tree sub RecurseDirs { my ($path) = @_; my $file; #Variable for a file foreach $path($path){ opendir (DIRECTORY, $path) || die "Can't read $path\n"; if (-d "$path$file/") { #If it's a directory... # Recurse again through this directory &RecurseDirs("$path$file/"); my $unused = 0; #Counter for how many files are accessed my $count = 0; #Counter for how many files are in dir # Count unused files in dir $path find -type f -atime +180 >temp.txt; $str = wc temp -l; $unused = int::substr($str, 0, 1); #returns the first character as an int # Count files in dir $path find -type f >temp.txt; $str = wc temp -l; $count = int::substr($str, 0, 1); #returns the first character as an int # Compare # Yes: write full dir path to file if (($unused * 2) > $count){ $path >>result.txt; } } closedir (DIRECTORY); } }