Operators

 # ==

if [ 'Girish' == 'Girish' ];

then

    echo "same" #output

else

    echo "not same"

fi


# !=

if [ 'Girish' != 'Apple' ];

then

    echo "not same" #output

else

    echo "same"

fi


# -n

if [ -n "Girish" ];

then

    echo "not null" #output

else

    echo "null"

fi


# -z

if [ -z "Girish" ];

then

    echo "null"

else

    echo "not null" #output

fi



==========================


# -eq

if [ 10 -eq 10 ];then

echo "Equal"

fi


# -ge

if [ 10 -ge 9 ];then

echo "Greater or equal"

fi


# -gt

if [ 10 -gt 8 ];then

echo "Greater"

fi


# -le

if [ 10 -le 12 ];then

echo "Less than or equal"

fi


# -lt

if [ 10 -lt 13 ];then

echo "Less than"

fi


# -ne

if [ 10 -ne 13 ];then

echo "Not Equal"

fi

Comments

Popular posts from this blog

LP 1

Class File

Dependencies