//View Tip #882
Similar Tips
» Counts files in the current directory and subdirectory
» Find occurrences of a string in a large code base without firing
» My code is compiling
» Find files greater than a certain size
» Local/remote webserver

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
To find the last modified files in a directory you can use ls -ltr. To find the last modified file on a file system it will not work, but the following command will work:

find /etc -type f -printf "%T@ %T+ %p" | sort -n


View Comments »



Comments 

Add your comment

CAPTCHA

No HTML allowed. URLs will be linked with nofollow attribute. Whitespace is preserved.

Nice one.  I had to add a \n after the %p, though.
Posted 2009-09-15 11:01:36
Yes, I also had to add '\n'.  I also piped through 'sort -rn|head' to limit the output.  It's also possible to speed things up by using the test '-cnewer' in 'find'.  Just picking any file in the directory your searching.  If you don't get any output you've managed to pick the most recent modified file.
Posted 2009-09-16 00:30:55
sudo find /etc -type f -printf "%T@ %T+ %p \n" | sort -n | less
Posted 2009-09-20 06:51:15
MacThunder
Why so complicated?
I am used to:

find . -type f -mtime 0
Posted 2010-06-10 02:31:34
i believe you are a good writer, but have you erver thought to write some special artcals for peopel who likes shopping very much.
Posted 2010-07-15 22:42:45

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit