[CentOS] find most recent file update in directory

Fri Dec 9 15:09:27 UTC 2011
Windsor Dave L. (AdP/TEF7.1) <Dave.Windsor at us.bosch.com>

On 12/9/2011 9:27 AM, John R. Dennison wrote:
> On Fri, Dec 09, 2011 at 03:15:53PM +0100, Mogens Kjaer wrote:
>>
>> Try something like:
>>
>> find . -type f -printf '%A@ %p\n' | sort -n | tail -1
> 
> I believe you want %T@ instead of %A@ (modification time versus access
> time).  I would also suggest sort -nr to sort from most recent to least
> recent.
> 
> 
> 							John

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.

Best Regards,

Dave Windsor

Robert Bosch LLC
Team Leader, MES Database Infrastructure Group (AdP/TEF7.1) 
Anderson, SC USA