Results 1 to 2 of 2
I need to write a script that is given a directory as an argument, and it prints the last modified file from that directory and all its subdirectories.
for example:
...
- 05-28-2010 #1Just Joined!
- Join Date
- May 2010
- Posts
- 4
Find last modified file in current directory and all subdirectories
I need to write a script that is given a directory as an argument, and it prints the last modified file from that directory and all its subdirectories.
for example:
$ newest /usr/etc
--> /usr/etc/httpd/httpd May 28 12:16
If I had to do it only for the current dir, it would be easy...
I'd probably use "ls -lt" and then show only the first line...
But this "all subdirectories" thingy complicates the things for me.
How should I do it?
THANK YOU!
- 05-29-2010 #2Just Joined!
- Join Date
- Dec 2007
- Posts
- 14
Add -R to your ls command, that will list the files recursively


Reply With Quote