2017-08-07 79 views
0

我知道如何將foreach用作shell腳本。但是,我遇到了一個有線問題,比方說,我想只是打印文件夾的名字,我可以這樣做:tcsh foreach one liner只顯示第一個對象

foreach f (*/) 
    echo $f 
    end 

,輸出將是1/2/3/ 但是,假設我想要做到這一點作爲一個班輪:

foreach f (*/) ; echo $f ; end 

首先,它不會結束,它會讓我進入另一個「結束」來完成的foreach,和我做之後,它只會顯示第一元素,而不是像以前一樣遍歷所有文件夾。

有人知道爲什麼會發生這種情況,我該怎麼做才能正常工作?

謝謝。

回答

0

從人的tcsh

The foreach, switch, and while statements, as well as 
the if-then-else form of the if statement, require that 
the major keywords appear in a single simple command 
on an input line as shown below.