Created
November 1, 2013 20:36
-
-
Save waffle2k/7271562 to your computer and use it in GitHub Desktop.
A simple little Perl script that takes an epoch, and a regular expression that captures an epoch within a filename, then deletes said file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use Getopt::Long; | |
$|++; | |
my ( $cutoff, $re ); | |
GetOptions ( | |
"regex=s" => \$re, | |
"epoch=i" => \$cutoff, | |
) or die "Invalid arguments: $!"; | |
die 'invalid epoch' unless ( $cutoff =~ /^\d+$/ ); | |
while( <> ){ | |
chomp; | |
if( $re and /$re/o and $1 < $cutoff and -e $_ ){ | |
print "$_\n" and unlink $_; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment