comparing lengths of strings

 
#! bin/bash
# comparing lengths of strings

echo "enter the 1st string"
read st1

echo "enter the 2nd string"
read st2


if [ "$st1" \< "$st2" ]
then
echo "$st1 is smaller than $st2"
elif [ "$st1" \> "$st2" ]
then
echo "$st1 is greater than $st2"
else
echo "above strings are equal"
fi



[prabhucloudxlab@cxln4 ~]$ sh hello.sh
enter the 1st string
linuxhint
enter the 2nd string
lin
linuxhint is greater than lin



[prabhucloudxlab@cxln4 ~]$ sh hello.sh
enter the 1st string
lin
enter the 2nd string
linuxhint
lin is smaller than linuxhint



[prabhucloudxlab@cxln4 ~]$ sh hello.sh
enter the 1st string
linuxhint
enter the 2nd string
linuxhint
above strings are equal



[prabhucloudxlab@cxln4 ~]$ sh hello.sh
enter the 1st string
hariprabhu
enter the 2nd string
haritaraka
hariprabhu is smaller than haritaraka