开发者

find and number of days range

开发者 https://www.devze.com 2023-04-03 02:48 出处:网络
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.

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

精彩评论

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