lundi 29 juin 2015

How to use multiple condition in if statement in bash?

Actually I am a new bash learner. I can use one condition in bash command. But how to use multiple condition in bash? I can use if statement like this:

read a
if [ $a = "y" ] ; then
   echo "YES"
elif [ $a = "Y" ] ; then
   echo "YES"
else
   echo "NO"
fi

I am finding something like this:

read a b c

if [ $a -eq $b and $b -eq $c ] ; then
    echo "EQUILATERAL"
elif [ $a -eq $b or $b -eq $c ] ; then
    echo "ISOSCELES"
else
    echo "SCALENE"
fi

I just want to know, what to use instead of and and or?

Aucun commentaire:

Enregistrer un commentaire