查找和天数范围 [英] find and number of days range

查看:72
本文介绍了查找和天数范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试用bash归档脚本编写代码,但似乎无法使find()以天数为间隔进行工作.

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.

我需要编码的范围是

  1. 文件的最后修改时间是今天至31天.这有效:

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

  1. 文件的最后修改时间为31天至62天.这不起作用:

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

  1. 文件的最后修改时间为62天至93天之间
  2. 文件的最后修改时间为93天至124天之间
  3. ...您知道了(直到一年)....

有没有一种方法可以对我的find()命令进行编码以使用若干天的范围?

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

这表明:mtime大于31天但小于61天的文件.

This tells: files with a mtime greater than 31 days but less than 61 days.

这篇关于查找和天数范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆