Bash shell script to check the equality of given numbers
kw.sh
#!/bin/bash

echo "———————————————————————————————————————————"
echo "Script to check the equality of given numbers"
echo "———————————————————————————————————————————"
echo -n "Enter the 1st number "; read a
echo -n "Enter the 2nd number "; read b
if [ $a -gt $b ];then
    echo "$a is greater than $b"
elif [ $a -eq $b ];then
    echo "$a is equal to $b"
else
    echo "$a is less than $b"
fi
echo "———————————————————————————————————————————"
Output
kodingwindow@kw:~$ bash kw.sh
———————————————————————————————————————————
Script to check the equality of given numbers
———————————————————————————————————————————
Enter the 1st number -5
Enter the 2nd number -10
-5 is greater than -10
———————————————————————————————————————————

kodingwindow@kw:~$ bash kw.sh
———————————————————————————————————————————
Script to check the equality of given numbers
———————————————————————————————————————————
Enter the 1st number 0
Enter the 2nd number 0
0 is equal to 0
———————————————————————————————————————————
kodingwindow@kw:~$ 
Bash shell script to check the equality of given strings
kw.sh
#!/bin/bash

echo "———————————————————————————————————————————"
echo "Script to check the equality of given strings"
echo "———————————————————————————————————————————"
echo -n "Enter the 1st string "; read a
echo -n "Enter the 2nd string "; read b 
if [ $a = $b ];then
    echo "$a is equal to $b"
else
    echo "$a is not equal to $b"
fi
echo "———————————————————————————————————————————"
Output
kodingwindow@kw:~$ bash kw.sh
———————————————————————————————————————————
Script to check the equality of given strings
———————————————————————————————————————————
Enter the 1st string WELCOME
Enter the 2nd string welcome
WELCOME is not equal to welcome
———————————————————————————————————————————
kodingwindow@kw:~$ 
Advertisement