shell 字符串比较是否相等 报错[: =: unary operator expected

shell 字符串比较是否相等  报错[: =: unary operator expected

egg:

a = '123'

b='1234'

if [  $a  ==  $b ];then

echo "相等"

fi

此时报错[: =: unary operator expected

正确写法  多加个[ ]:

if [[  $a  ==  $b ]];then

echo "相等"

fi

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章