find command has a great operator for narrowing down the list of results: mtime.
as you probably know from the atime, ctime and mtime post, the mtime is a file property confirming the last time the file was modified.
find uses mtime option to identify files based on when they were modified.
Typical ways of using find mtime are shown below.
Find files modified in the last 24 hours
Thi can be useful for identifying current log files, like this:
Each of the files from this list has been updated today. You can use the exec option of the find command to invoke ls command and show timestamps for each file:
Find files modified more than 7 days ago
This doesn’t have to be 7 days, you can specify any number here. This command is useful for confirming which (log) files haven’t been modified for more than a week – it could mean they are safe to delete.
This is how a start of such a list would look (bear in mind I’m running this on October 20th, 2018):
Find all the files modified in the last 30 days
Again, this doesn’t have to be exactly 30 days, it can be any number. I’m using 30 because it’s roughly 1 month and is a round enough number for backup/restore points.
Here I’m checking what’s been updated in my home directory in the past 30 days: