使用 find 查找自上次早上 6 点后未修改的文件

Using find to locate files that haven't been modified since the last time it was 6 AM

我想要一个 cron 作业来删除自上次早上 6 点以来未更改的文件。可能不是很清楚,所以这里有一个例子:

这就是为什么我不能只使用

find /path/ -type f ! -newermt '06:00:00' -delete

我该怎么做?

先检查是否过了早上 6 点,然后将参数相应地修改为 -newermt

if (( $(date +%-H) < 6 )); then
  when='yesterday 6'
else
  when='6'
fi
find /path/ -type f ! -newermt "$when" -print