find: missing argument to `-exec'

今天写一个清理脚本,用到了find命令。

本来是这么写的:

find . -type f -mtime +7 -name "*.log" -exec rm -rf {} \

结果报错,find: missing argument to `-exec'

后来一查,发现两个会导致此问题的原因。

1. "{}"和"\"之间要有空格
 
2. 此语句末尾需要分号

很显然,我没加分号。
 
所以将此shell语句末尾加一个分号即可正常运行。

find . -type f -mtime +7 -name "*.log" -exec rm -rf {} \;

猜你喜欢

转载自www.cnblogs.com/young233/p/11986633.html