1

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

open mockups/dashboard/* mockups/widget/singleproduct/* mockups/widget/carousel/*

我想让它适用于模型下面的任何子目录集。

我可以显示所有子目录:

find mockups -type d -print

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

谢谢!

4

1 回答 1

2

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

从手册页:

-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 实例,例如:

find mockups -type f -exec open {} +
于 2013-05-08T15:36:07.320 回答