Take the 2-minute tour ×
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
3  
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

3 Answers 3

up vote 12 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

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
6  
-cmin is "status change", -mmin is "data change". You probably want -mmin –  Eelvex Jan 17 '12 at 0:01

Your Answer

 
discard

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.