bash腳本防止可變迭代我有一個bash腳本中,我限定一定的路徑作爲這樣:在for循環
MY_PATH=/to/my/path
我也有一組my_path的內的目錄,並予儲存這些目錄中一個數組,因此:
DIRECTORIES="/dir1/
/dir2/
/dir3/"
我想要做的是疊代在$ my_path的所有$目錄,所以我想這:
for dir in $MY_PATH$DIRECTORIES
do
echo "Processing $dir"
end
然而,這提供了以下不需要輸出:
Processing /to/my/path/dir1/ #Correct!
Processing /dir2/ #What I want: Processing /to/my/path/dir2/
Processing /dir3/ #What I want: Processing /to/my/path/dir3/
有什麼辦法來防止重複超過$ my_path的同時保留迭代超過$目錄,以便我能達到預期的輸出(見上文)?
哦是的,杜。謝謝! – laker