[CentOS] find most recent file update in directory

John R. Dennison jrd at gerdesas.com
Fri Dec 9 20:06:59 UTC 2011


On Fri, Dec 09, 2011 at 10:09:27AM -0500, Windsor Dave L. (AdP/TEF7.1) wrote:
> I like:
> 
> find . -type f -printf '%TY/%Tm/%Td %TH:%TM:%TS %p\n' | sort -n | tail -1
> 
> which shows the last access date/time in a human-readable format that also sorts nicely (YYYY/MM/DD HH:MM:SS).
> 
> Note that some distros include fractional values with the seconds
> (%TS), making it even more accurate.  My CentOS 5.7 server does not,
> my Kubuntu 11.10 desktop does.

I considered that as well, but as you point out it will not properly
order files due to lack of second resolution.  One can stick an "-ls" on
find to get human-readable timestamps on the returned file list if
necessary.




							John
-- 
Be in charge of your own destiny, or some one else will.

-- John Francis "Jack" Welch, Jr. (1935-), past Chairman
   and CEO of General Electric 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20111209/ead3fe7e/attachment.sig>


More information about the CentOS mailing list