On Wed, Jan 09, 2008 at 02:29:19PM -0800, Wayne Johnson wrote:
> Anyone know of a quick and easy way to find the date of the newest
> file in a directory tree.  

Not entirely "quick" when dealing with a million files, but

find /some/dir/ -exec ls -l {} \; | awk '{print $6,$7,$8}' | sort -r | head -1

will give you the newest file in /some/dir/ (or its subdirectories)
along with its modification date and time, assuming your ls lists the
date/time in an ascii-sortable format (which mine does: 2008-01-09 00:28).

> I'm looking for a way to speed up synchronizing file caches between
> machines.  When you have 1m in files (that's a count, not a size), it
> takes quite a while to scan through the whole tree.  If we had a
> .oldest file in each branch, we could skip that branch if nothing had
> changed.  Then all we would need to do is scan the tree once to set
> these branch-stamps.  After that, all the cache machines would have to
> do is walk the tree looking for newer stamps.  

Have you tried rsync?  In broad terms, this is the kind of thing it's
designed to handle, but I'm not sure whether it's able to detect
unmodified directories and skip them or not.

-- 
I reckon we are now the only monastry ever that had a dungeon stuffed with
sixteen thousand zombies.
  - perlmonks.org