查找和天数范围

发布于 2024-12-03 13:50:16 字数 498 浏览 0 评论 0原文

我尝试在 bash 中编写一个归档脚本,但我似乎无法让 find() 以天数间隔工作。

我需要编码的范围是

  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. ...你明白了(最多一年)......

有没有办法对我的发现进行编码()命令使用天数范围?

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 old
  3. ...you get the idea (up to year)....

Is there a way to code my find() command to use a number of days range??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2024-12-10 13:50:16

我认为你必须改变times中+和-的逻辑:

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

这说明:mtime大于31天但小于61天的文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文