dimanche 2 avril 2017

comparing blank variable using if statement

When i am comparing a blank variable with a string i am getting below error

[: !=: unary operator expected

Below is line in my script

if [ $monthlystatus != Failed ];then

command to execute

When i try to change this as below

if [ "$monthlystatus" = Completed ];then

command to execute

It does not give me expected result i.e. if statement does not work properly. I also try using [[ ]] but it does not work i.e. error is gone but if statement does not work.

Aucun commentaire:

Enregistrer un commentaire