in reply to Cleaning up by age
Hope this helps.my $debug = 1; my @oldest_10_files = ( map { $_->[1] } sort { $b->[0] <=> $a->[0] } map { [ -M $_, $_ ] } glob( "/path/to/directory/*" ) )[0..9]; unlink @oldest_10_files unless $debug; print "The following files have been removed\n\n", join "\n", @oldest_ +10_files;
Update: The above code utilizes the Schwartzian Transform. Thanks, Jonathan for pointing out the oversight.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Cleaning up by age
by Jonathan (Curate) on Nov 15, 2001 at 18:21 UTC | |
by FoxtrotUniform (Prior) on Nov 20, 2001 at 22:21 UTC |