Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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).

share|improve this question
    
Run man ls for a full list of options including various sort possibilities. –  Caleb Jun 10 '11 at 7:39
add comment

1 Answer 1

up vote 8 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.