Return to Snippet

Revision: 19834
at November 1, 2009 13:25 by deepsoul


Initial Code
find directory -type f | perl -e 'my $l=0; my $n=""; while( <> ) { chomp; my $t= ${[stat($_)]}[9]; $t > $l and ($l= $t, $n= $_); } print "$n\t".localtime($l), "\n";'

Initial URL

                                

Initial Description
Find the most recently modified file in a directory tree and output its name and modification time.  Use index 8 or 10 instead of 9 for access and inode modification time, respectively (see perlfunc manual page - function stat).

This is great for deciding what directories to backup.

Initial Title
Find newest file and its modification time

Initial Tags
perl, find

Initial Language
Bash