I tried to code in bash an archiving script but I can't seem to get find() working with an interval in number of days.
The ranges I need to code are
- files last modified between today and 31 days old. This works:
find . -name "*.VER" -mtime -31 -exec mv '{}' /opt/html/31';' -print
- files last modified between 31 days and 62 days old. This does not work:
find . -name "*.VER" -mtime -31 -mtime -62 -exec mv '{}' /opt/html/62 ';' -print
- files last modified between 62 days and 93 days old
- files last modified between 93 days and 124 days ol开发者_JAVA百科d
- ...you get the idea (up to year)....
Is there a way to code my find() command to use a number of days range??
I think you have to change the logic of + and - in the times:
find . -name "*.VER" -mtime +31 -mtime -62 -exec mv '{}' /opt/html/62 ';' -print
This tells: files with a mtime greater than 31 days but less than 61 days.
精彩评论