查找:`-exec`缺少参数

时间:2019-11-26 15:11:43

标签: shell sh

我正在尝试使我的Shell脚本正常运行,但是我一直在获取:find: missing argument to '-exec'

#!/bin/sh
echo Hello World
find ./public_html/var/session/ -type f -name "sess*" -mtime +30 -exec rm -f {} \;
echo DONE

我一直试图在这些解决方案中寻求帮助,但遗憾的是,没有一个解决了我的问题。
Shell script - find: missing argument to `-exec'
find: missing argument to -exec

1 个答案:

答案 0 :(得分:1)

另一个不涉及-exec的选项是将结果通过管道传递到xargs,然后在其上rm

find ./public_html/var/session/ -type f -name "sess*" -mtime +30 | xargs rm -f

man xargs

注意: xargs支持与-P命令并行执行,请参见手册页。

相关问题