To find files by age, use find’s -mtime flag. The sign works backwards from what feels natural.
The Fix
find . -mtime -1 # modified less than 1 day ago
find . -mtime +7 # modified more than 7 days ago
find . -mtime 3 # modified exactly 3 days ago (rarely what you want)
For finer granularity, -mmin does the same thing in minutes:
find . -mmin -60 # modified in the last hour
Why the Sign Feels Backwards
-n means “less than n”, +n means “more than n”. Read -1 as “younger than 1 day” and +7 as “older than 7 days”, not as a literal day count.
Gotchas
-mtimeis content modification time.-atimeis last access time, and many filesystems don’t update it on every read, so it’s an unreliable “last used” signal.- A bare
-mtime 3(no sign) means exactly between 3 and 4 days old, which almost nobody wants. Use-1/+nranges instead.