On Wed, Jan 09, 2008 at 05:30:21PM -0600, Dave Sherohman wrote:
> On Wed, Jan 09, 2008 at 05:20:14PM -0600, Florin Iucha wrote:
> > On Wed, Jan 09, 2008 at 04:57:04PM -0600, Dave Sherohman wrote:
> > > 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
> > 
> > Ewwwww... ETOOMANYLS
> > 
> > find /some/dir -type f -printf "%h/%f %A@\n" | sort -rn -k2 | head -1
> 
> *bows*  Yours is the superior find-fu.  I wasn't even aware it had a
> -printf option.
> 
> But wouldn't you want %T@ (mtime) rather than %A@ (atime), since we're
> looking for the most recently modified file?

Yup, you are right.

And the Oscar goes to:

find /some/dir -type f -printf "%h/%f %T@\n" | awk '{ if ($2 > the_max) { the_max = $2; file_name = $1; } }
END { print file_name }'

I would like to thank Google for its search engine and to the find
man page for its thorough description of the million options and
switches...

florin

-- 
Bruce Schneier expects the Spanish Inquisition.
      http://geekz.co.uk/schneierfacts/fact/163
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20080109/cbf68997/attachment.pgp