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 Commented Nov 28, 2011 at 10:36
  • I'm getting: stat: illegal option -- c usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...] Commented Nov 28, 2011 at 11:50
  • Which distro are you using? Commented Nov 28, 2011 at 14:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.