2013-05-08 69 views
1

請幫助我找到語法。我試圖複製這一命令,將打開的所有文件在每個指定子目錄的效果:使用find打開子目錄中的所有文件

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

我想使它成爲任何低於設定樣機子目錄的工作。

我可以告訴所有子目錄:

find mockups -type d -print 

但我不知道如何使用xargs的在「*」添加。另外,我不想單獨使用「-exec open {} \;」單獨執行每個文件的open操作,因爲這會啓動50個不同的Preview預覽副本,而當我需要的是預覽的一個實例時,將加載50個文件。

謝謝!

回答

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. 

這意味着,開放盡可能少的情況下,將被執行儘可能,例如:

find mockups -type f -exec open {} + 
+0

完美,謝謝! – dankohn 2013-05-08 16:01:12

相關問題