使用exec命令的linux find永远不会结束

时间:2016-03-19 13:43:16

标签: linux find infinite-loop

这是我正在调用的命令:

find / -name zad1.sh -size -50M -mtime -1 -exec grep "do" {} \;

然后它回显了两行是正确的:

do
done

然而,它继续做某事而且从不停止。我必须手动执行Ctrl + C来终止进程。谁能向我解释一下这里发生了什么? 附:我是类Unix系统的新手。(我正在研究Cygwin)

1 个答案:

答案 0 :(得分:0)

您必须添加 -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.

聚苯乙烯。改变"做"用'做' ;双引号内插字符串,执行是bash的关键字。