shell脚本if判断时报[: missing ]
源代码:
if [ -d "test"] then echo dir named test exsited! elif [ ! -d "test"];then mkdir test cd test fi
报错:
[: missing ]
原因在于if判断在" ] "前面没有加空格,加上空格后就行了。
if [ -d "test" ] then echo dir named test exsited! elif [ ! -d "test" ];then mkdir test cd test fi