How do I list directories by their access time in the sense that some new files/directories are created (say, directories containing the most recently created files).
Asked
Active
Viewed 7.2k times
1 Answers
32
There are a couple of options that you can combine.
The -c
switch sorts by time modified [1]:
-c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise:
sort by ctime
The -u
and -t
switches can also be used:
-t sort by modification time
-u with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time
You could put it all together like so [2]:
ls -ltcr # sort by and show change time, most recent last
ls -ltur # sort by and show access time, most recent last
ls -ltr # sort by date, most recent last
[1] http://unixhelp.ed.ac.uk/CGI/man-cgi?ls
[2] -r
reverses the order

jasonwryan
- 73,126
man ls
for a full list of options including various sort possibilities. – Caleb Jun 10 '11 at 07:39