How to get files listed within specific time range
-
04-12-2019 - |
Question
How can I list files within specific time range:
- Files those modification date isn't greater than 5 hours.
- Files that fall into period like 10-th of December through 20-th of December.
Solution
find /YOUR/SEARCH/DIR -type f -mmin -300 2> /dev/null
Finds every file for your first criteria.
For the second:
touch -d "2011-12-10" 2012-12-10
touch -d "2011-12-21" 2012-12-21
find /YOUR/SEARCH/DIR -type f -anewer 2012-12-10 ! -anewer 2012-12-21 2> /dev/null
It first creates two reference files based on your date criterias, then search by using them.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow