lundi 23 novembre 2015

Compare two strings in shell, one coming from a command return

I'd like to compare two strings to know if my Bluetooth is on or off using blueutil

I tried this :

cd ../../../usr/local/bin
./blueutil status
a=$(./blueutil status)
printf "$a\n"
if ["$a"="Status: on"]
    then echo "ok"
else
    echo "not ok"
fi

But the return is

Status: on
Status: on
not ok

What is wrong with my test in the if statement?

Thanks in advance for your help!

Aucun commentaire:

Enregistrer un commentaire