for $_ (`locate $ARGV[0]`) {
chop;
-M and $f{$_}=$^T-(3600*24*(-M _));
}
for $x (sort { $f{$a} <=> $f{$b} } keys %f) {
printf "%s $x\n", scalar localtime($f{$x});
}
Ideally, you could even have perl grep through
the "locate" database (locatedb) itself, and eliminate
the system calls altogether.
| [reply] [Watch: Dir/Any] [d/l] |
ewww... replace all that -M garbage with just
(stat $_)[9]!
| [reply] [Watch: Dir/Any] [d/l] |
Yeah...it was late when I wrote that. For prettiness, both
could be used:
-M and $f{$_}=(stat _)[9];
Note: the initial test (the -M above) could also be
almost any of the file tests - it is needed because
locate returns a list of files that existed when
the locate database was last compiled, but may not exist
now. Also, the files may *exist*, but you may not be able
to get information on them due to rights.
| [reply] [Watch: Dir/Any] [d/l] |
[anders@localhost anders]$ perl -e 'for (`locate $ARGV[0]`) {\
chomp; $h{$_} = (stat $_)[9] \
}\
foreach $k ( sort {$h{$a} <=> $h{$b} } keys %h) {\
print scalar localtime $h{$k}, ": $k\n" }' filename
Thu Jul 29 11:20:32 1999: /usr/lib/xemacs/xemacs-packages/lisp/apel/fi
+lename.elc
Wed Nov 3 12:52:33 1999: /usr/bin/getfilename
Wed Nov 3 12:52:34 1999: /usr/man/man1/getfilename.1.bz2
Mon Dec 20 08:47:16 1999: /usr/man/mann/filename.n
Mon Jan 3 20:57:21 2000: /usr/share/zsh/functions/Commands/_correct_f
+ilename
-anders
| [reply] [Watch: Dir/Any] [d/l] |