求大神帮忙

qimiaojiuen 2017-08-26 07:15:09
请问各位大神
find /etc/ -name "http*" -type f -exec cp {} /tmp/fhttp.file \;
这句命令里面的 -exec的作用是干什么的? -exec cp {} /tmp/fhttp.file \;是干什么的?
...全文
727 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
糖炒唐朝栗子 2017-08-28
  • 打赏
  • 举报
回复
exec 将前面的结果放到{}中 \;不可缺少, 也就是说将前面find找到的文件 拷贝并重命名到/tmp/fhttp.file
ipqtjmqj 2017-08-26
  • 打赏
  • 举报
回复
-exec command ;
Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to the command until an argument consisting of ';' is encountered. The string '{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find. Both of these constructions might need to be escaped (with a '\') or quoted to protect them from expansion by the shell. See the EXAMPLES section for examples of the use of the -exec option. The specified command is run once for each matched file. The command is executed in the starting directory. There are unavoidable security problems surrounding use of the -exec action; you should use the -execdir option instead.

查看find命令用法说明
-exec空格后面接的是句命令直接分号为止,也就是cp {} /tmp/fhttp.file这一句是命令
其中{}代表找到的文件,所有找到的文件都会依次执行这个命令
斜杠是转义

427

社区成员

发帖
与我相关
我的任务
社区描述
非技术问题的乐园
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧