Shell 用于查找超过 4 天的文件并移动的脚本

Shell script to find file older than 4 days and move

如何在下面的代码中包含超过 4 天的文件?

尝试使用“-mtime +3”测试一些变体,但它给我语法错误。用于查看文件是否存在并在超过 4 天前移动的功能。

#!/bin/ksh
FILE=test.txt
 if [ -f "$FILE" ]
   then mv "$FILE" "$FILE.old"
 fi

我搜索了很多线程,都使用 find 命令。

谢谢

find . -mtime +3 作品:

$ cd -- "$(mktemp --directory)"
$ touch --date='4 days ago' old
$ touch new
$ find . -mtime +3
./old

你试过那个变体吗?如果有,你有哪一个find