我+
在使用像find
.
来自SO post 的示例-
find -exec touch -t 201007162310.00 \+
Run Code Online (Sandbox Code Playgroud)
请帮助我理解这个的用法。
lge*_*get 10
来自man find
:
-exec 命令 {} +
Run Code Online (Sandbox Code Playgroud)This variant of the -exec action runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invocations of the command will be much less than the number of matched files. The command line is built in much the same way that xargs builds its command lines. Only one instance of `{}' is allowed within the command. The command is executed in the starting directory.
例如find -exec touch -t 201007162310.00 \+
,如果不带 的 find 命令-exec
为您提供文件1.txt
,2.txt
和3.txt
,它将执行:
touch -t 201007162310.00 1.txt
touch -t 201007162310.00 2.txt
touch -t 201007162310.00 3.txt
Run Code Online (Sandbox Code Playgroud)
没有\+
, 和
touch -t 201007162310.00 1.txt 2.txt 3.txt
Run Code Online (Sandbox Code Playgroud)
与\+
.
后一个版本速度更快,因为需要的新进程数量(少得多)但可移植性较差(并非所有find
实现都支持它)。当然,如果您尝试使用的命令-exec
不支持接收多个文件作为参数,则它将不起作用。