-
Notifications
You must be signed in to change notification settings - Fork 33
/
fcheck.pl
executable file
·47 lines (33 loc) · 1.23 KB
/
fcheck.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
# Author: Trizen
# Date: 23th September 2013
# https://trizenx.blogspot.com
# Display all the files from a given directory with
# size greater than N and modified in or after a given date.
# usage: perl fcheck.pl [/my/dir] [MB size] [day.month.year]
use strict;
use warnings;
use File::Spec qw();
use File::Find qw(find);
use Time::Local qw(timelocal);
my $dir = @ARGV
? shift() # first argument
: File::Spec->curdir(); # or current directory
my $min_size = @ARGV
? shift() * 1024**2 # second argument
: 100 * 1024**2; # 100MB
my $min_date = @ARGV
? shift() # third argument
: '10.09.2013'; # 10th September 2013
# Converting date into seconds
my ($mday, $mon, $year, $hour, $min, $sec) = split(/[\s.:]+/, $min_date);
my $min_time = timelocal($sec, $min, $hour, $mday, $mon - 1, $year);
sub check_file {
lstat;
-f _ or return; # ignore non-files
-l _ and return; # ignore links
(-s _) > $min_size or return; # ignore smaller files
(stat(_))[9] >= $min_time or return; # ignore older files
print "$_\n"; # we have a match
}
find {no_chdir => 1, wanted => \&check_file} => $dir;