I can fire

ls -lrt 

to get files and folders sorted by modification date, but this does not separate directories from files. I want ls to show me first directories by modification date and then files by modification date. How to do that?

2 Answers 2


what about something like this:

ls -ltr --group-directories-first
  • Great, thanks! Somehow I was not able to find this from the man page. My bad, thanks!
    – jrara
    Commented Aug 11, 2013 at 9:49

ls -t

or (for reverse, most recent at bottom):

ls -tr

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

Directories have d in front of there permissions in ls -ltr

So to get directories with sorted modification date use

ls -ltr |grep ^d

And to files other than directories

ls -ltr | grep -v ^d

  • No, this does not produce the correct result.
    – jrara
    Commented Aug 11, 2013 at 9:39
  • superuser.com/questions/147027/… Commented Aug 11, 2013 at 9:41
  • You are correct about folders, I updated question.
    – jrara
    Commented Aug 11, 2013 at 9:41
  • Thanks for your answer, but if you read my question carefully, you might notice that I already know how to sort ls output by modification date (ls -lrt), but not how to sort results so that I get directories first by mod date and then files by mod date.
    – jrara
    Commented Aug 11, 2013 at 9:44
  • hey jrara i have got your question.. i am getting back with the answer... Commented Aug 11, 2013 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .