Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

How can I list recursively all files that were changed between 22.12.2011 and 24.12.2011?

share|improve this question
If you mean 'last changed', you have a chance at a solution. If a file was modified on 26.12.2011, you cannot tell if it was also modified during your given range. (Unless you have a very exotic file system.) –  William Pursell Jan 17 '12 at 2:07

5 Answers 5

up vote 15 down vote accepted

Generally speaking, when you're looking for files in a directory and its subdirectories recursively, use find.

The easiest way to specify a date range with find is to create files at the boundaries of the range and use the -newer predicate.

touch -t 201112220000 start
touch -t 201112240000 stop
find . -newer start \! -newer stop
share|improve this answer

Using Gilles' solution and after reading the man find(1) again I found a more simple solution. The best option is the -newerXY. The m and t flags can be used.

m   The modification time of the file reference
t   reference is interpreted directly as a time

So the solution is

find . -type f -newermt 20111222 \! -newermt 20111225

The lower bound in inclusive, and upper bound is exclusive, so I added 1 day to it! And it is recursive. It works well on find v4.5.9.

share|improve this answer
Cool trick, thanks! That helped me with finding a recent file containing a certain keyword in a directory with thousands of files: find -newermt 20150212 \! -newermt 20150213 | xargs grep 'keyword' -m 50 -l (-m 50 = search in first 50 lines). –  Rob W Feb 13 at 10:20
@RobW: Actually you can spare the pipe and xargs using -exec ... + in find(1), like: find -newermt 20150212 \! -newermt 20150213 -exec grep keyword -m 50 -l {} +. This does the same, but cheaper. –  TrueY Feb 13 at 10:27

Assuming you don't need precision to the seconds, this should work.

find . -type f -mmin -$(((`date +%s`-`date -d 20111222 +"%s"`)/60)) \! -mmin +$(((`date +%s`-`date -d 20111224 +"%s"`)/60))

EDIT: Changed cmin to mmin after @Eelvex's comment. EDIT: '\!' missing

share|improve this answer
hm doesnt seem to work. are you sure it recursively walks through the subdirectories? –  clamp Jan 16 '12 at 22:29
Yes, it works on me. Do you really have files modified in that time range? Try it with different time ranges. –  onur güngör Jan 16 '12 at 22:32
-cmin is "status change", -mmin is "data change". You probably want -mmin –  Eelvex Jan 17 '12 at 0:01

find can take an ISO formatted datetime, so for a server on UTC for instance, you could specify an offset of a number of hours from wherever you are. This also takes care of having to add a day since you're comparing time too:

find -type f -newermt 20111224T0800 \! -newermt 20111225T0800
share|improve this answer

In addition to the answers already given, note that you can directly specify your dates:

find -type f -newermt "2011-12-22" \! -newermt "2011-12-24"


find -type f -newermt "2011-12-22 00:00:00" \! -newermt "2011-12-24 13:23:00"

if you additionally want to specify the time.

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.