Shell Script to Find Simple Interest
echo "Enter Amount:"
read p
echo "Enter Time:"
read t
echo "Enter ROI:"
read r
i=` expr $p \* $t \* $r `
i=` expr $i / 100 `
echo "Simple Interest is: $i"
Shell Program to Print Multiplication Table
echo "Enter a Number"
read n
i=0
while [ $i -le 10 ]
do
echo " $n x $i = `expr $n \* $i`"
i=`expr $i + 1`
done
Shell Program to Print Multiplication Table up to
Given Range
echo "Enter a Number"
read n
echo "Enter Range"
read r
i=0
while [ $i -le $r ]
do
echo " $n x $i = `expr $n \* $i`"
i=`expr $i + 1`
done
Shell Script to find Greatest of Three numbers
echo "Enter three Integers:"
read a b c
if [ $a -gt $b -a $a -gt $c ]
then
echo "$a is Greatest"
elif [ $b -gt $c -a $b -gt $a ]
then
echo "$b is Greatest"
else
echo "$c is Greatest!"
fi
Shell Script to Check Leap Year
echo "Enter Year:"
read y
year=$y
y=$(( $y % 4 ))
if [ $y -eq 0 ]
then
echo "$year is Leap Year!"
else
echo "$year is not a Leap Year!"
fi
Shell Script to find Number is Even or Odd
echo "Enter a Number:"
read n
rem=$(( $n % 2 ))
if [ $rem -eq 0 ]
then
echo "Number is even"
else
echo "Number is odd"
fi
Shell Script to find Side of a Square
echo "Enter side of a Square:"
read s
echo "Area of Square: ` expr $s \* $s `"
Shell Script to Reverse a Number
echo "Enter a Number:"
read a
rev=0
sd=0
or=$a
while [ $a -gt 0 ]
do
sd=`expr $a % 10`
temp=`expr $rev \* 10`
rev=`expr $temp + $sd`
a=`expr $a / 10`
done
echo "Reverse of $or is $rev"
Shell Script to Find Sum of Digits
echo "Enter a Number:"
read n
temp=$n
sd=0
sum=0
while [ $n -gt 0 ]
do
sd=$(( $n % 10 ))
n=$(( $n / 10 ))
sum=$(( $sum + $sd ))
done
echo "Sum is $sum"
Shell Script to Perform String Comparison
echo "Enter First String:"
read string1
echo "Enter Second String:"
read string2
if [ $string1 -eq $string2 ]
then
echo "Strings are equal!"
else
echo "Strings are not equal!!"
fi
Shell Script to Check Number is Positive or
not
echo "Enter a Number:"
read n
if [ $n -gt 0 ]
then
echo "Number is positive"
else
if [ $n -eq 0 ]
then
echo "Number is Zero!"
else
echo "Number is Negative!!"
fi
fi