Compare integer in bash, unary operator expected

前端 未结 4 1433
谎友^
谎友^ 2020-12-04 05:44

The following code gives

[: -ge: unary operator expected

when

i=0

if [ $i -ge 2 ]
then
    #some code
fi
         


        
4条回答
  •  伪装坚强ぢ
    2020-12-04 06:39

    Judging from the error message the value of i was the empty string when you executed it, not 0.

提交回复
热议问题