我想要做一些類似下面的循環來找到路徑中的所有「* e-0 [1-9]」目錄(1e-04 ,3e-07等等)。如果找到這樣的目錄,我想要執行一些命令。我的問題是如果條件,這給了我不同的錯誤使用sh或bash。我得到的sh的錯誤是「[:unexpected sequence」,對於bash是「[:too many arguments]」。我在stackoverflow的不同問題中發現了這個問題,但是這些問題主要與if條件中從「==」到「=」的轉換有關,在這裏不是這種情況。問題部分看起來像這樣:
for i in `seq 1 9`;
do
directory=*e-0$i
// directory="*e-0"+$i // also tried things like that
if [ -d ${directory} ] // THIS is the line stated in the error
then
echo $directory
fi
done
在此先感謝。
引用! 'if [-d「$ {directory}」]' – fedorqui 2014-11-06 12:54:08