I am on linux and have tried to figure out the find command for a while to be able to list the directories modified in a 24 hour period a certain number of days ago, but I can't get it to work. Among other things I have tried:
find -type d -mtime +1 -mtime -2
But it returns 0 matches, while find -type d -mtime +1
gives 16721 matches and find -type d -mtime -2
gives 120 matches. I should get around 50-60 matches.
I have also tried the -a
option for AND
in between but it makes no difference.
The arguments for the
-mtime
option to find are a little counter-intuitive. Basically, what you're asking for there is "show me everything that's older than two days ago, and younger than two days ago"... the '+' option is a little wonky (fromfind
(1)):For a single day range, you can just use
-mtime 2
, otherwise I suggest going to using-mmin
and a bit of shell arithmetic to get where you want to go.I'd use a script:
Much easier to understand than
-mtime
.