tags:

views:

528

answers:

2

Let's say I have a directory like-

/home/user/

and I want to list EVERY file (even in sub directories) under that folder and order them by the date they were last edited.

Can I and if so, how?

Thanks!

+6  A: 

You can use:

$ ls -Rt

where -R means recursive (include subdirectories) and -t means "sort by last modification date".

mipadi
Thanks, that's perfect.I added a -l in there too so I can actually see the dates so for anyone who searches this out later, it's-$ ls -lRt
Marty
If you're doing this at the prompt and want to see the most recently modified files, consider `ls -lrt[RhA]`. the `-r` reverses the sort order, leaving recently edited stuff at the bottom of the list...
dmckee
+2  A: 

If you'd like a master list in which all the files are sorted together by modification date, showing the directory they're in, but not grouped by directory, you can use this:

find . -type f -printf "%-.22T+ %M %n %-8u %-8g %8s %Tx %.8TX %p\n" | sort | cut -f 2- -d ' '

The result looks a lot like ls -l:

-rw-r--r-- 1 root     root         3892 08/11/2009 11:03:36 /usr/share/man/man1/xmllint.1.gz
-rw-r--r-- 1 root     root        22946 08/13/2009 11:59:20 /usr/share/man/man1/curl.1.gz
-rw-r--r-- 1 root     root          728 08/17/2009 12:06:33 /usr/share/man/man1/thunderbird.1.gz
-rw-r--r-- 1 root     root          873 08/18/2009 10:52:47 /usr/share/man/man1/libgnutls-config.1.gz
-rw-r--r-- 1 root     root         2552 08/19/2009 02:00:34 /usr/share/man/man3/Purple.3pm.gz
-rw-r--r-- 1 root     root         9546 08/19/2009 02:02:00 /usr/share/man/man1/pidgin.1.gz
-rw-r--r-- 1 root     root         2201 08/19/2009 02:02:46 /usr/share/man/man3/Pidgin.3pm.gz
-rw-r--r-- 1 root     root          926 08/19/2009 02:03:05 /usr/share/man/man1/purple-remote.1.gz
-rw-r--r-- 1 root     root        18052 08/19/2009 04:11:47 /usr/share/man/man1/mono.1.gz
-rw-r--r-- 1 root     root         1845 08/19/2009 04:11:47 /usr/share/man/man5/mono-config.5.gz
Dennis Williamson
Nice one. The whole directory grouping thing with ls -R is annoying.
El Yobo