Revision: 3498
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 2, 2007 19:33 by iblis
Initial Code
#!/usr/bin/perl -w use strict; # use File::stat; # for detailed print out use Getopt::Std; # ### get options and the argument from the command line my %opts; getopts("amc", \%opts); my $operator='-M'; # date modified to present if ($opts{'a'}) {$op='-A'}; # date accessed to present if ($opts{'c'}) {$op='-C'}; # inode change time to present # my $path = shift or die "Usage: $0 [ -a | -m | -c] path\n"; opendir my($dir), $path or die "Can't open $path : $!\n"; # ### store file names sorted by modification or access date # my @files = sort { eval($operator.' "$path/$a" <=> '.$operator.' "$path/$b"') } grep { -f "$path/$_" } readdir $dir; # ### with -M operator in clear # # my @files = sort { -M "$path/$a" <=> -M "$path/$b" } # grep { -f "$path/$_" } # readdir $dir; ### same with -A and -C # closedir $dir; # ### Simple print out # foreach my $file (@files) {print "$file\n";}; # ### Detailed print out # foreach my $file (@files) {my $sb = stat("$path/$file"); printf "%s : last modified on %s, last accessed on %s\n", $file, scalar localtime $sb->mtime, scalar localtime $sb->atime;}
Initial URL
Initial Description
Lists last modified (or accessed) files. Based on a hint by Master Jedai at http://www.developpez.net/forums/showpost.php?p=2302596&postcount=4
Initial Title
Sort files by date modified or accessed
Initial Tags
Initial Language
Perl