Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The linux locate command is great at finding files quicky.

My question: how can we use the locate command so that the results are returned in date/time order?

share|improve this question

How about:

ls -td $(locate something)


ls -td1 $(locate something)
share|improve this answer
Maybe a -d would be handy, too. – choroba Aug 27 '12 at 11:47
@choroba: good point, I'll update the answer. – RedGrittyBrick Aug 27 '12 at 11:49

This works as long as there are not spaces in the filenames, but errors if there are too many files (see

$ ls -td $(locate sh)
bash: /bin/ls: Argument list too long

This will work even with spaces or other characters in filenames, but doesn't sort correctly with too many files:

locate something -0 | xargs -0 ls -ltd

The following will always work (although it might take awhile):

locate something -0 | xargs -0 stat -c'%Y %n' | sort -n
share|improve this answer

You must log in to answer this question.

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