首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用“查找”打开子目录中的所有文件

使用“查找”打开子目录中的所有文件
EN

Stack Overflow用户
提问于 2013-05-08 23:01:22
回答 1查看 127关注 0票数 1

你能帮我找语法吗?我正在尝试复制此命令的效果,该命令打开每个指定子目录中的所有文件:

代码语言:javascript
复制
open mockups/dashboard/* mockups/widget/singleproduct/* mockups/widget/carousel/*

我想让它在模型下面的任何一组子目录下都能工作。

我可以用以下命令显示所有子目录:

代码语言:javascript
复制
find mockups -type d -print

但是我不确定如何使用xargs添加"*“。此外,我不想使用"-exec open {} \;“为每个文件单独执行open,因为这会启动50个不同的预览副本,而我需要的是一个预览版实例,其中加载了50个文件。

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-08 23:36:07

我手头上的find版本允许在-exec参数后指定一个+符号:

从手册页:

代码语言:javascript
复制
-exec command {} +
              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.

这意味着将执行尽可能少的open实例,例如:

代码语言:javascript
复制
find mockups -type f -exec open {} +
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16444018

复制
相关文章

相似问题

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