find

find-exec 选项中,以 ; 结尾(注意 shell 转义)是对每个文件单独运行命令。而 + 结尾是对所有文件用 xargs 的形式运行命令。可以从以下例子看出:

$ find . -name '*.cu' -exec echo {} +
./basic_interop.cu ./ripple.cu ./heat.cu
$ find . -name '*.cu' -exec echo {} \;
./basic_interop.cu
./ripple.cu
./heat.cu

-depth 选项让 find 以深度优先的顺序访问文件,这样文件夹就一定比其包含的子文件后访问,这对于删除等工作非常重要。

find 有一些 global options,要在正确位置使用,不清楚可以 man find 查一下。比如 -mindepth-maxdepth-depth 都是 global options。

To prevent confusion, global options should specified on the command-line after the list of start points, just before the first test, positional option or action.