当我在 Ubuntu 中运行此脚本时:
for item in *
do
if [ -d $item ]
then
echo $item
fi
done
我得到了这个输出: output
我不明白为什么我得到“[:if-then:意外的运算符”
最佳答案
转义变量。了解它 here .
for item in *
do
if [ -d "$item" ]
then
echo "$item"
fi
done
关于linux - 搜索文件夹中的所有子文件夹时,得到 "[: if-then: unexpected operator ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52418947/