使用shell中的[]测试字符串需要注意的地方

shell中的[]可以用来做各种测试,在测试比较时,比如字符串的比较,必须给字符串加上双引号,否则会报[too many arguements的错误
a='abc'
if [ "$a" ];then
echo $a
fi

猜你喜欢

转载自blog.51cto.com/13560219/2439434