这是我正在调用的命令:
find / -name zad1.sh -size -50M -mtime -1 -exec grep "do" {} \;
然后它回显正确的两行:
do
done
但是,它会继续做某事并且永不停止。我必须手动执行 Ctrl+C 终止进程。谁能向我解释这里发生了什么? 附言我是类 Unix 系统的新手。(我在 Cygwin 上工作)
最佳答案
你必须添加-quit选项;来自联机帮助页:
-quit Exit immediately. No child processes will be left running, but
no more paths specified on the command line will be processed.
For example, find /tmp/foo /tmp/bar -print -quit will print only
/tmp/foo. Any command lines which have been built up with
-execdir ... {} + will be invoked before find exits. The exit
status may or may not be zero, depending on whether an error has
already occurred.
附言。将“做”改为“做”;双引号内插字符串,do 是 bash 的关键字。
关于linux find with exec 命令永远不会结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36102506/