The document contains the code for several Bash shell programs that perform tasks like calculating factorials, checking for palindromes, generating Fibonacci sequences, reversing strings, comparing numbers and strings, and determining if a year is a leap year. Each program section includes the code, an output header, and sample run outputs showing the program working as expected for different inputs.
3. PALINDROME
PROGRAM:
clear
echo Enter the String
read s
echo $s > temp
rs="$(rev temp)"
if [ $s = $rs ]
then
echo It is Palindrome
else
echo It is not Palindrome
fi
9. GREATER OF THE THREE NUMBERS
PROGRAM:
echo "Enter The No.1:"
read a
echo "Enter the No.2:"
read b
echo "enter the NO.3:"
read c
if [ $a -gt $b ]
then
if [ $a -gt $c ]
then
echo "No1 is Greater"
fi
elif [ $b -gt $c ]
then
echo "No2 is Greater"
else
echo "No3 is Greater"
fi
17. PRIME OR NOT
PROGRAM:
clear
echo Enter the No..
read n
c=0
i=2
t=$(($n-1))
while [ $i -le $t ]
do
q=$(($n%$i))
if [ $q -eq 0 ]
then
c=$(($c+1))
fi
i=$(($i+1))
done
if [ $c -eq 0 ]
then
echo It is Prime
else
echo It is Not Prime
fi
19. POSITVE NEGATIVE & ZERO
PROGRAM:
echo Enter The No.
read n
if [ $n -gt 0 ]
then
echo $n is Positive
elif [ $n -lt 0 ]
then
echo $n is Negative
else
echo $n is Zero
fi
23. COMPARING THE STRING
PROGRAM:
clear
echo Enter The 1st String::
read s1
echo Enter The 2nd String::
read s2
if [ $s1 = $s2 ]
then
echo Strings Are Equal
else
echo Strings Are Not Equal
fi
24. OUTPUT:
Enter The 1st String::
System
Enter The 2nd String::
System
Strings Are Equal
25. LEAP YEAR
PROGRAM:
clear
echo "Leap Year"
echo "Enter the Year.:"
read n
s=$(($n%4))
if [ $s -eq 0 ]
then
echo "$n is Leap year"
else
echo "$n is Not Leap Year"
fi