Home » Questions » Computers [ Ask a new question ]

How can I sort the output of 'ls' by last modified date?

How can I sort the output of 'ls' by last modified date?

How can I sort the output of ls by last modified date?

Asked by: Guest | Views: 259
Total answers/comments: 4
bert [Entry]

"For a complete answer here is what I use: ls -lrth

Put this in your startup script /etc/bashrc and assign an alias like this: alias l='ls -lrth' Restart your terminal and you should be able to type l and see a long list of files."
bert [Entry]

"Mnemonic

For don't ignore entries starting with . and sort by date (newest first):

ls -at

For don't ignore entries starting with . and reverse sort by date (oldest first):

ls -art

For don't ignore entries starting with ., use a long listing format and sort by date (newest first):

ls -alt

For print human readable sizes, don't ignore entries starting with ., use a long listing format and sort by date (newest first) (@EvgeniSergeev note):

ls -halt

but be careful with the last one, because a simple mistype can cause a server crash... (@Isaac note)"
bert [Entry]

"Find all files on the file system that were modified maximally 3 * 24 hours (3 days) ago till now:

find / -ctime 3"
bert [Entry]

"To show 10 most recent sorted by date, I use something like this:

ls -t ~/Downloads | head -10

or to show oldest

ls -tr ~/Downloads | tail -10"