How to find files on a server, which came on specific time period say 1 Jan to 31 March using grep, without scripts? Thanks!
Asked
Active
Viewed 84 times
1 Answers
0
Can I answer with a command without grep
?
find /path -type f -daystart \
-mtime -$(( ($(date +%s) - $(date +%s -d '2015-01-01 -1 day')) /60/60/24 )) \
-mtime +$(( ($(date +%s) - $(date +%s -d '2015-03-31 23:59:59')) /60/60/24 ))
This will find any file in the /path
directory whose modification time is between 2015-01-01 00:00:00
and 2015-03-31 23:59:59
expressed as days ago.
I.e. today is 2015-06-29
, so the command line will be expanded as
find /path -type f -daystart -mtime -180 -mtime +89

MaxChinni
- 1,206
- 14
- 21
-
Please don't answer off-topic questions such as this one, because it belongs to [su] and is not about programming. – Artjom B. Jun 29 '15 at 14:00
-