School of Information Technology and Engineering B.Tech It Information Technolgy Opearting Systems - Ite 209
School of Information Technology and Engineering B.Tech It Information Technolgy Opearting Systems - Ite 209
Shell Program 1
echo "Enter 1st numbner"
read a
echo "Enter 2nd number "
read b
echo "Enter 3rd number "
read c
echo "the 1st number is $a"
echo "the 2nd number is $b"
echo "the 3rd number is $c"
if [ $a -lt $b ]
then d=$a
else d=$b
fi
if [ $c -lt $d ]
then d=$c
fi
echo "The smallest number is $d"
read m2
echo "Enter subject3 marks : "
read m3
total=`expr $m1 + $m2 + $m3`
avg=`expr $m1 / 3`
if [ $avg -ge 90 ]
then
echo " Grade = A "
elif [ $avg -ge 80 ]
then
echo " Grade = B"
elif [ $avg -ge 70 ]
then
echo " Grade = C "
elif [ $avg -ge 60 ]
then
echo " Grade = D "
elif [ $avg -ge 60 ]
then
echo " Grade = E+ "
elif [ $avg -ge 50 ]
then
echo " Grade = E "
else echo " Grade = F "
fi
Shell Program 3
Shell Program 2
read a
read b
echo " Initially, a = $a "
echo "
b = $b "
a=`expr $a + $b`
b=`expr $a - $b`
a=`expr $a - $b`
echo " After Swapping, a = $a "
echo "
b = $b "
echo "Printing grade of the students "
echo "Enter name "
read name
echo "Enter subject1 marks : "
read m1
echo "Enter subject2 marks : "
esac
Shell Program 6
Shell Program 4
echo "enter a number :"
read n
sum1=0
sum=0
while [ $n -ne 0 ]
do
r=`expr $n % 10`
n=`expr $n / 10`
sum=`expr $sum \* 10`
sum=`expr $sum + $r`
sum1=`expr $sum1 + $r`
done
echo the reversed number is $sum
echo the sum of individual digits is $sum1
Shell Program 5
echo Comparison of 2 strings
echo Enter the 1st string
read s1
echo Enter the 2nd string
read s2
if [ $s1 = $s2 ]
then echo Equal
else echo Not Equal
fi
if [ -z $s1 ]
then echo 1st string is null
else echo 1st string is not null
fi
if [ -z $s2 ]
then echo 2nd string is null
else echo 2nd string is not null
fi
Shell Program 7
echo Reversing command line arguments
for i in $*
do
a=$i
b="$a $b"
done
echo $b
Shell Program 8
echo Enter value of n
read n
c=1
s=0
while [ $c -le $n ]
do
s=`expr $s + $c`
c=`expr $c + 1`
done
echo "the sum of n natural numbers is $s"