我想要做一些类似下面的循环来找到路径中的所有“* 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