Tuesday, January 1, 2013

IF ELSE & IF ELIF IF in Shell Script

#!/bin/bash
x=10
y=20
echo "Value x=$x y=$y"
if [ $x -eq $y ] ; then
        echo -e " x and y are same value "
elif [ $x -gt $y ] ; then
        echo -e " x is greater than y "
else
        echo -e " x is less than y"
fi

str1="Chidam"
str2="Chidam"
echo "Value str1=$str1 str=$str2"
if [ "$str1" = "$str2" ] ; then
        echo -e " str1 and str2 are same value "
else
        echo -e " str1 and str2 are not same value "
fi


OUTPUT :

-bash-3.2$ sh if_elif_ex
Value x=10 y=20
 x is less than y
Value str1=Chidam str=Chidam
 str1 and str2 are same value

No comments:

Post a Comment

Item - Category Query

      SELECT      msi.segment1 AS Item_Code,       msi.DESCRIPTION AS Item_Desc,       mcs.CATEGORY_SET_NAME,       mck.CONCATENATED_SEGMEN...