Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I can't find the answer on Google without digging around, an there is no answer on Stack Overflow either.

share|improve this question
46  
You guys need to chill - the answer isn't there on Google without digging around, and there isn't to my knowledge a duplicate on SO. Question asked, question answered, move on. – nearly_lunchtime Apr 9 '09 at 13:26
4  
Ehm... There actually is an answer on Google, it's right there in the ls man page. – Tom Wijsman Aug 28 '11 at 14:55
13  
@nearly_lunchtime, You should consider accepting the answer with 70 votes. It's not nice to leave questions as "unanswered" when they clearly are. – recluze Feb 16 '12 at 1:58
I think Tom Wijsman's comment is a perfectly valid answer. – Vorac Sep 12 '12 at 6:02

migrated from stackoverflow.com May 30 '10 at 19:58

7 Answers

ls -t

or (for reverse, most recent at bottom):

ls -tr

The ls man page describes this in more details, and lists other options.

share|improve this answer
3  
Thanks, the -r option was helpful. – Scott Warren May 9 '11 at 12:22
33  
Why not accepting it, then? – Massimo Oct 13 '11 at 7:54
Because Scott Warren wasn't the questioner. – Tommy Herbert May 31 at 10:17

Using -t:

ls -t
share|improve this answer

Try this: ls -ltr. It will give you the recent to the end of the list

share|improve this answer
3  
how did you answer this almost 3 days before the question was asked? Tempted to upvote for Kreskin-like ESP. – glenn jackman Apr 8 '10 at 21:23
16  
@glenn jackman: The question is asked in year 2009, and this answer is belongs to 2010 – huseyint May 30 '10 at 12:45

Pass the -t flag:

$ ls -t
share|improve this answer

option: -t

share|improve this answer

Add:

alias lt='ls -Alhtr'

in $homedir/.bashrc

share|improve this answer

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.

share|improve this answer

protected by Nifle Aug 16 '12 at 18:15

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.