Hello,
I try to find in a directory hicharchy the most recent time of file update.
I think, there could be a solution with find?
Thank you for help in advance
Best regards Helmut Drodofsky
On 12/09/2011 02:41 PM, Helmut Drodofsky wrote:
Hello,
I try to find in a directory hicharchy the most recent time of file update.
I think, there could be a solution with find?
Try something like:
find . -type f -printf '%A@ %p\n' | sort -n | tail -1
Mogens
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
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
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
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.
What's wrong with ls -laFrt?
mark
Always Learning wrote:
On Fri, 2011-12-09 at 10:23 -0500, m.roth@5-cent.us wrote:
What's wrong with ls -laFrt?
Everything !
Its not intellectual enough and its too short and its also simple.
Ok, then ls -ZlaFrt | tail -1 | sort | tail -1
That better?
mark "is the obfuscated shell script contest next?"
On Fri, Dec 09, 2011 at 03:26:26PM +0000, Always Learning wrote:
Its not intellectual enough and its too short and its also simple.
You left out "incorrect".
John
From: "m.roth@5-cent.us" m.roth@5-cent.us
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.
What's wrong with ls -laFrt?
The OP said "in a directory hicharchy"...
JD