2012-06-25 37 views
1

所有find和執行的例子是這樣的變化(與/bin/rm):如何查找並執行?

find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f 

,但我找不到如何找到並運行文件(假設它們是可執行的)。

那麼,如何從bash腳本中查找並執行文件?

我試了一下這樣的(以及類似的變化):

find $ROOT_PATH -executable -name unittests_runner.exe -exec {} 

回答

3

你只需要添加一個「\;」在你行的末尾,如:

find $ROOT_PATH -executable -name unittests_runner.exe -exec {} \; 

等瞧...

+0

感謝。很簡單 –

2

試試這個:

for `find $ROOT_PATH -executable -name unittests_runner.exe`; do 
    `$i` 
done 

順便說一句:

`something` 

${something} 
速記

,它的意思是「在那裏執行凡是」

0

我想嘗試這樣的:

find $ROOT_PATH -executable -type f | xargs /bin/bash