Server Fault is a question and answer site for system and network administrators. 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

Is there a shell command to find the newest created files recursively from a root directory?

share|improve this question
up vote 7 down vote accepted
find /mydir -type f -exec stat -c '%y %N' {} \; | sort -n
share|improve this answer
You may want to tweak "%y". Refer to "man stat". – Zimmy-DUB-Zongy-Zong-DUBBY Sep 3 '09 at 20:08
In general, you should avoid using -exec for security reasons. GNU find offers -execdir as an alternative. – geocar Sep 3 '09 at 20:50

This method uses only find (and sort):

find /somedir -type f -printf "%T+ %p\n" | sort

You can constrain it to the most recent 3 days, for example, like this:

find . -type f -mtime -3 -printf "%T+ %p\n" | sort

Or the last 42.5 hours:

find . -type f -mmin -2550 -printf "%T+ %p\n" | sort

which is the same as:

find . -type f -mmin -$((42 * 60 + 30)) -printf "%T+ %p\n" | sort
share|improve this answer

To avoid forking one process per file checked, if you're on a machine with GNU versions of find and xargs, consider something like this:

find /dir -type f -print0 | xargs -0 stat -c '%Y %N' | sort -n
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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