开发者

find and number of days range

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

  1. files last modified between today and 31 days old. This works:

find . -name "*.VER" -mtime -31 -exec mv '{}' /opt/html/31';' -print

  1. 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

  1. files last modified between 62 days and 93 days old
  2. files last modified between 93 days and 124 days ol开发者_JAVA百科d
  3. ...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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜