8

How can I sort the results of find? I want to sort by date created asc?

find /docs -type f | sort

Sorts by filename not date created. Thanks.

1 Answer 1

12

AFAIK, Linux doesn't record the creation time, so the short answer is you cannot.

For the modification time, try this:

$ find /docs -type f -printf '%T@ %p\n' | sort -k1 -n

or:

$ find /docs -type f -print0 | xargs -0 stat -c "%y %n" | sort
3
  • 2
    You beat me too it! Justin, for some discussion on what ctime actually means, look at perlmonks.org/?node_id=741616
    – cjc
    Nov 28, 2011 at 10:36
  • I'm getting: stat: illegal option -- c usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]
    – Justin
    Nov 28, 2011 at 11:50
  • Which distro are you using?
    – quanta
    Nov 28, 2011 at 14:51

You must log in to answer this question.

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