fcheck.pl 1.2 KB

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