This question already has an answer here:

I want to use find but sort the results reverse chronologically as with ls -ltr. Is this possible through any combo of flags or pipelines?

marked as duplicate by don_crissti, Anthon, Jeff Schaller, G-Man, Satō Katsura May 4 '17 at 6:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Use find's -printf command to output both the time (in a sortable way) and the file, then sort. If you use GNU find,

find . your-options -printf "%T+\t%p\n" | sort
  • 6
    sort -r for reverse order. – stnly Jan 24 '12 at 15:12
  • 7
    ls -t sorts newer to older, sort sorts older to newer. So ls -t's reverse order is sort's normal order. – angus Jan 24 '12 at 15:19
  • 1
    Do you have a version for OS X (non-gnu)? – Ortomala Lokni Aug 25 '16 at 15:48
  • 5
    For OS X and non-GNU, use this answer. – Tom Hale Jan 11 '17 at 4:46
  • 4
    To get this to work with OSX, install findutils from homebrew, then use gfind not find. stackoverflow.com/questions/752818/… – Chris Mar 5 '18 at 0:44

If that is just a depth-n (assume depth-2) folder hierarchy, I find this one useful:

ls -laht --full-time */*
  • This seems to produce a list of files that are exactly two folders deep (no more, no less), along with separate listings of each of the folders that are exactly two folders deep. – mwfearnley Feb 12 '17 at 13:42
  • 1
    @mwfearnley that is exactly what I meant by "that is just a depth-n" above :) you can do */*/* if you want depth 3 – Ben Usman Feb 13 '17 at 17:25
  • 1
    So basically, your suggestion only works as intended when all the files are exactly n levels deep, and there are no subfolders at that level. You should explain that. The latter might be surmountable by another flag for ls, and you can perhaps cover all levels up to n with ls ... * */* */*/* ... – mwfearnley Feb 14 '17 at 9:26

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