查找和天数范围
我尝试在 bash 中编写一个归档脚本,但我似乎无法让 find() 以天数间隔工作。
我需要编码的范围是
- 从今天到 31 天之间最后修改的文件。这有效:
find 。 -name "*.VER" -mtime -31 -exec mv '{}' /opt/html/31';' -print
- 文件上次修改时间在 31 天到 62 天之间。这不起作用:
find 。 -name "*.VER" -mtime -31 -mtime -62 -exec mv '{}' /opt/html/62 ';' -print
- 文件上次修改时间在 62 天到 93 天之间
- 文件上次修改时间在 93 天到 124 天之间
- ...你明白了(最多一年)......
有没有办法对我的发现进行编码()命令使用天数范围?
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 old
- ...you get the idea (up to year)....
Is there a way to code my find() command to use a number of days range??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你必须改变times中+和-的逻辑:
这说明:mtime大于31天但小于61天的文件。
I think you have to change the logic of + and - in the times:
This tells: files with a mtime greater than 31 days but less than 61 days.