//View Tip #882
» Count files by type
» Filter stderr for cron jobs
» SVN resolve all conflicts
» Delete old files
Rob Hutten
Similar Tips
» Duplicate directory tree» Count files by type
» Filter stderr for cron jobs
» SVN resolve all conflicts
» Delete old files
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
Comments
Add your comment
#1
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

