如图所示
find -L /etc/ssl/certs/ -type l -exec rm {} +所以它会找到所有破碎的符号链接并删除它们。但是,我如何确切地解释{} +部分呢?
发布于 2009-10-09 15:17:37
{}位是exec命令的占位符。由find找到的任何文件都会插入括号中。+意味着建立一个很长的文件列表,并同时调用所有文件的exec,而不是一次调用一个文件,就像更传统的-exec {} \;变体一样。
发布于 2009-10-09 15:15:17
来自man find:
-exec command {} +
This variant of the -exec option 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 invoca-
tions 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.因此,它将调用命令:
rm [filename1] [filename2] [...] [lastfilename]如果参数列表中包含的文件太多,那么rm将被多次调用。(这就是xargs所做的。)
如果没有{} +,它只会在没有参数的情况下多次调用rm。
https://serverfault.com/questions/72978
复制相似问题