首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rm {} +做什么?

rm {} +做什么?
EN

Server Fault用户
提问于 2009-10-09 15:12:55
回答 2查看 8.7K关注 0票数 5

如图所示

代码语言:javascript
复制
find -L /etc/ssl/certs/ -type l -exec rm {} +

所以它会找到所有破碎的符号链接并删除它们。但是,我如何确切地解释{} +部分呢?

EN

回答 2

Server Fault用户

回答已采纳

发布于 2009-10-09 15:17:37

{}位是exec命令的占位符。由find找到的任何文件都会插入括号中。+意味着建立一个很长的文件列表,并同时调用所有文件的exec,而不是一次调用一个文件,就像更传统的-exec {} \;变体一样。

票数 9
EN

Server Fault用户

发布于 2009-10-09 15:15:17

来自man find

代码语言:javascript
复制
   -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.

因此,它将调用命令:

代码语言:javascript
复制
rm [filename1] [filename2] [...] [lastfilename]

如果参数列表中包含的文件太多,那么rm将被多次调用。(这就是xargs所做的。)

如果没有{} +,它只会在没有参数的情况下多次调用rm

票数 13
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/72978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档