SlideShare a Scribd company logo
1
Solution manual of Shell programming Assignment – 2
1. Write a Shell Script to find the reverse of a given number Using WC.
Shell Script Output
2. Write a Shell Script to generate Fibonacci Series.
Shell Script Output
3. Write a Shell Script to display Mathematical Table for a given number
Shell Script
2
Output
4. Write a Shell Script to copy the content of a file to another file.
Shell Script
Output
3
5. Write a Shell Script to count the number of Vowels, Number of Consonants and Number
of digits present in a given String.
Shell Script
Output
4
6. Write a Shell Script to accept file name & convert its contents from lower to upper case.
Shell Script
Output
7. Write a shell script that will receive a name interactively from the user during execution
and prints a welcome message.(Say Hello <entered name>.Welcome to CSE Dept.,
Kalyani Govt. Engg. College !).
Shell Script
Output
8. Write a shell script that will receive a name interactively from the user during execution
and prints greetings according to the system time. (Example: say user enters “Anirban”
and if the system is less than 12.00 AM then the script will print : “Good Morning
Anirban” else if the system time is greater than 12.00 AM but less than 6.00 PM then
prints “Good After Noon Anirban” else if the system time is greater than 6.00 PM but
less than 8.00 PM then “Good Evening Anirban” else if the system time is greater than
8.00 PM but less than 12.00 PM then “Good Night Anirban”).
5
Shell Script
Output
9. Write a shell script that will receive a text filename(which contents a paragraph)
interactively from the user during execution and prints the following according to the
number of words present in the file: SHORT FILE(if the number of words is less than
100), MEDIUM FILE(if the number of words is greater than 100 but less than 350) ,
LARGE FILE( words greater than 350 but less than 500) and VERY LARGE FILE(words
greater than 500).
Shell Script
6
Output
10.Write a shell script that will receive a text filename as input and prints OFFICIAL FILE if
the first line of the file contains the string “KGEC” only else prints UNOFFICIAL FILE. If
the file is an OFFICIAL FILE then the program will prints number of words and characters
present in the first 10 lines, it also appends string “Accessed on: <current date-time
stamp>” at the end of the file.
Shell Script
Output
11.Write a shell script (check_exam.sh) that will use a file “exam_schedule.txt” to check
whether there is any exam today or not. If there is no exam today then it will print: NO
7
EXAM TODAY. The file “exam_schedule.txt” must contain three fields as EXAM
DATE(dd/mm/yyyy), EXAM TIME and EXAM PAPER. For example:
03/02/2014 10.00AM OPTICAL_NETWORK
04/02/2014 10.00AM IMAGE_PROCESSING
……… ……….. ……………..
Shell Script
Output
12.Write a shell script that will take the basic salary (BS) as runtime input from the user and
calculates the DA (5% if BS is less than or equal to 10,000, above 10,000 it becomes
15%), HRA(5% if BS is less than or equal to 10,000, above 10,000 it becomes 7%) and
finally calculates the gross salary(gross salary=BS+DA+HRA).
8
Shell Script
Output
13.Write a shell script to display the following menu:
i. Length of the string
ii. Reverse of the string
iii. Copy one string to another.
Shell Script
echo "Enter a string: "
read str
echo "i. Length of string"
echo "ii.Reverse of the string"
echo "iii. copy one string into another."
echo "Enter your choice: "
read c
case "$c" in
i)x=`echo $str | wc -c`
x=`expr $x - 1`
echo "Length is : $x";;
ii)x=`echo $str | wc -c`
x=`expr $x - 1`
while [ $x -gt 0 ]
do
c=`echo $str | cut -c $x`
s=$s$c
x=`expr $x - 1`
done
echo "The Reverse of string is : $s";;
iii)s=$str
echo "The copied string is : $s";;
esac
9
Output
14.Write a shell script to check whether a given number is prime or not.
Shell Script
echo "Enter a number: "
read num
i=2
f=0
while [ $i -le `expr $num / 2` ]
do
if [ `expr $num % $i` -eq 0 ]
then
f=1
fi
i=`expr $i + 1`
done
if [ $f -eq 1 ]
then
echo "The number is composite"
else
echo "The number is Prime"
fi
Output
15.Write a shell script to check whether a given number is an Armstrong number or not.
Shell Script
echo "Enter a number: "
read c
x=$c
sum=0
r=0
n=0
while [ $x -gt 0 ]
do
r=`expr $x % 10`
n=`expr $r * $r * $r`
sum=`expr $sum + $n`
x=`expr $x / 10`
done
if [ $sum -eq $c ]
then
echo "It is an Armstrong Number."
10
else
echo "It is not an Armstrong Number."
fi
Output
16.Write a shell script to find the sum of the first n numbers.
Shell Script
echo "Enter a number: "
read num
i=1
sum=0
while [ $i -le $num ]
do
sum=`expr $sum + $i`
i=`expr $i + 1`
done
echo "The sum of first $num numbers is: $sum"
Output
17.Write a shell script to find a sum of given no and to check out to see if it is even or odd.
Shell Script
echo "Enter a number: "
read n
sum=0
x=$n
r=0
while [ $x -gt 0 ]
do
r=`expr $x % 10`
sum=`expr $sum + $r`
x=`expr $x / 10`
done
if [ `expr $sum % 2` -eq 0 ]
then
echo "The sum of $n is $sum and it is even"
else
echo "The sum of $n is $sum and it is odd"
fi
11
Output
18.Write a shell script to find a factorial of a given number.
Shell Script
fact=1
ie=1
echo -e "Enter a number:c"
read a
while [ $ie -le $a ]
do
fact=`expr $fact * $ie`
ie=`expr $ie + 1`
done
echo -e "Multilpication of $a number is $fact."
Output
19.Write a shell script that takes 2 numbers through K/B and finds the value of first number
raised to the power of second.
Shell Script
echo "Enter a number: "
read a
echo "Enter Power: "
read p
i=1
ans=1
while [ $i -le $p ]
do
ans=`expr $ans * $a`
i=`expr $i + 1`
done
echo "Answer of $a^$p is $ans"
Output
20.Write a shell script to read a string through keyboard and check whether it is
palindrome or not.
Shell Script
echo "Enter a string: "
12
read s
len=`echo $s | wc -c`
while [ $len -gt 0 ]
do
st=`echo $s | cut -c $len`
str=$str$st
len=`expr $len - 1`
done
if [ $str = $s ]
then
echo "String Palindrome"
else
echo "string is not palindrome"
fi
Output

More Related Content

PDF
HTML PPT.pdf
sunnyGupta325328
 
PPTX
Html notes with Examples
isha
 
PPTX
Program Threats
guestab0ee0
 
PPTX
MERN PPT
NeerajGupta96647
 
PPTX
Http protocol
Arpita Naik
 
PDF
Linux binary Exploitation - Basic knowledge
Angel Boy
 
PPTX
Html and css
Samiksha Pun
 
PPT
Php Ppt
vsnmurthy
 
HTML PPT.pdf
sunnyGupta325328
 
Html notes with Examples
isha
 
Program Threats
guestab0ee0
 
Http protocol
Arpita Naik
 
Linux binary Exploitation - Basic knowledge
Angel Boy
 
Html and css
Samiksha Pun
 
Php Ppt
vsnmurthy
 

What's hot (20)

PPT
Understanding IIS
Om Vikram Thapa
 
PDF
PHP file handling
wahidullah mudaser
 
PPTX
File Uploading in PHP
Idrees Hussain
 
PDF
Network telnet ssh
Stefan Fodor
 
PPT
Metadonnees Introduction
jbcomte
 
PDF
Html grade 11
Nelly Mofokeng
 
PPTX
Html formatting
Webtech Learning
 
PDF
Windows 10 Nt Heap Exploitation (Chinese version)
Angel Boy
 
PPT
javascript.ppt
MrsSChitradeviCommer
 
PPTX
Web development ppt
KBK Business Solutions
 
PPTX
Introduction to HTTP/2
Ido Flatow
 
PDF
Crontab
ARYA TM
 
PPTX
Php string function
Ravi Bhadauria
 
PPT
JavaScript Tutorial
Bui Kiet
 
PDF
OrientDB introduction - NoSQL
Luca Garulli
 
PPT
Css advanced – session 4
Dr. Ramkumar Lakshminarayanan
 
DOCX
College Web Site HTML PROJECT
Rai Saheb Bhanwar Singh College Nasrullaganj
 
PPT
Presentation on html, css
Aamir Sohail
 
Understanding IIS
Om Vikram Thapa
 
PHP file handling
wahidullah mudaser
 
File Uploading in PHP
Idrees Hussain
 
Network telnet ssh
Stefan Fodor
 
Metadonnees Introduction
jbcomte
 
Html grade 11
Nelly Mofokeng
 
Html formatting
Webtech Learning
 
Windows 10 Nt Heap Exploitation (Chinese version)
Angel Boy
 
javascript.ppt
MrsSChitradeviCommer
 
Web development ppt
KBK Business Solutions
 
Introduction to HTTP/2
Ido Flatow
 
Crontab
ARYA TM
 
Php string function
Ravi Bhadauria
 
JavaScript Tutorial
Bui Kiet
 
OrientDB introduction - NoSQL
Luca Garulli
 
Css advanced – session 4
Dr. Ramkumar Lakshminarayanan
 
College Web Site HTML PROJECT
Rai Saheb Bhanwar Singh College Nasrullaganj
 
Presentation on html, css
Aamir Sohail
 
Ad

Similar to Solution manual of shell programming assignment 2 (20)

DOCX
Shell programming assignment 2
Kuntal Bhowmick
 
DOCX
32 shell-programming
kayalkarnan
 
PDF
Unix Shell Scripting Tutorial | Unix Shell Scripting Online Training
Vyshnavi Reddy
 
DOCX
Quize on scripting shell
lebse123
 
PDF
Operating_System_Lab_ClassOperating_System_2.pdf
DharmatejMallampati
 
DOC
Linux Lab Manual.doc
Dr.M.Karthika parthasarathy
 
DOCX
Basic shell programs assignment 1
Kuntal Bhowmick
 
DOC
Unix prog
Mansi Patel
 
PDF
BASH Shell Scripting – Part II
Zeeshan Iqbal
 
DOCX
What is a shell script
Dr.M.Karthika parthasarathy
 
DOCX
The Korn Shell is the UNIX shell (command execution program, often c.docx
SUBHI7
 
PDF
Slides
abhishekvirmani
 
PPT
Unix
nazeer pasha
 
PDF
Shell script assignment 3
Kuntal Bhowmick
 
PDF
Introduction to base shell scripting
Zeeshan Iqbal
 
DOC
Operating Systems lab Programs - Fourth Semester - Engineering
Yogesh Santhan
 
PDF
Shell Scripting Intermediate - RHCSA+.pdf
RHCSA Guru
 
PPTX
Linux Shell Scripting
Raghu nath
 
PPTX
Bash Shell Scripting
Raghu nath
 
PPT
2-introduction_to_shell_scripting
erbipulkumar
 
Shell programming assignment 2
Kuntal Bhowmick
 
32 shell-programming
kayalkarnan
 
Unix Shell Scripting Tutorial | Unix Shell Scripting Online Training
Vyshnavi Reddy
 
Quize on scripting shell
lebse123
 
Operating_System_Lab_ClassOperating_System_2.pdf
DharmatejMallampati
 
Linux Lab Manual.doc
Dr.M.Karthika parthasarathy
 
Basic shell programs assignment 1
Kuntal Bhowmick
 
Unix prog
Mansi Patel
 
BASH Shell Scripting – Part II
Zeeshan Iqbal
 
What is a shell script
Dr.M.Karthika parthasarathy
 
The Korn Shell is the UNIX shell (command execution program, often c.docx
SUBHI7
 
Shell script assignment 3
Kuntal Bhowmick
 
Introduction to base shell scripting
Zeeshan Iqbal
 
Operating Systems lab Programs - Fourth Semester - Engineering
Yogesh Santhan
 
Shell Scripting Intermediate - RHCSA+.pdf
RHCSA Guru
 
Linux Shell Scripting
Raghu nath
 
Bash Shell Scripting
Raghu nath
 
2-introduction_to_shell_scripting
erbipulkumar
 
Ad

More from Kuntal Bhowmick (20)

PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Kuntal Bhowmick
 
PDF
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Kuntal Bhowmick
 
PPT
1. introduction to E-commerce
Kuntal Bhowmick
 
DOCX
Computer graphics question for exam solved
Kuntal Bhowmick
 
PDF
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 
PDF
Java questions for interview
Kuntal Bhowmick
 
PDF
Java Interview Questions
Kuntal Bhowmick
 
PDF
Operating system Interview Questions
Kuntal Bhowmick
 
PDF
Computer Network Interview Questions
Kuntal Bhowmick
 
PDF
C interview questions
Kuntal Bhowmick
 
PDF
C question
Kuntal Bhowmick
 
PDF
Distributed operating systems cs704 a class test
Kuntal Bhowmick
 
DOCX
Cs291 assignment solution
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Kuntal Bhowmick
 
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Kuntal Bhowmick
 
1. introduction to E-commerce
Kuntal Bhowmick
 
Computer graphics question for exam solved
Kuntal Bhowmick
 
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 
Java questions for interview
Kuntal Bhowmick
 
Java Interview Questions
Kuntal Bhowmick
 
Operating system Interview Questions
Kuntal Bhowmick
 
Computer Network Interview Questions
Kuntal Bhowmick
 
C interview questions
Kuntal Bhowmick
 
C question
Kuntal Bhowmick
 
Distributed operating systems cs704 a class test
Kuntal Bhowmick
 
Cs291 assignment solution
Kuntal Bhowmick
 

Recently uploaded (20)

PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
5.EXPLORING-FORCES-Detailed-Notes.pdf/8TH CLASS SCIENCE CURIOSITY
Sandeep Swamy
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PDF
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PDF
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
5.EXPLORING-FORCES-Detailed-Notes.pdf/8TH CLASS SCIENCE CURIOSITY
Sandeep Swamy
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Landforms and landscapes data surprise preview
jpinnuck
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 

Solution manual of shell programming assignment 2

  • 1. 1 Solution manual of Shell programming Assignment – 2 1. Write a Shell Script to find the reverse of a given number Using WC. Shell Script Output 2. Write a Shell Script to generate Fibonacci Series. Shell Script Output 3. Write a Shell Script to display Mathematical Table for a given number Shell Script
  • 2. 2 Output 4. Write a Shell Script to copy the content of a file to another file. Shell Script Output
  • 3. 3 5. Write a Shell Script to count the number of Vowels, Number of Consonants and Number of digits present in a given String. Shell Script Output
  • 4. 4 6. Write a Shell Script to accept file name & convert its contents from lower to upper case. Shell Script Output 7. Write a shell script that will receive a name interactively from the user during execution and prints a welcome message.(Say Hello <entered name>.Welcome to CSE Dept., Kalyani Govt. Engg. College !). Shell Script Output 8. Write a shell script that will receive a name interactively from the user during execution and prints greetings according to the system time. (Example: say user enters “Anirban” and if the system is less than 12.00 AM then the script will print : “Good Morning Anirban” else if the system time is greater than 12.00 AM but less than 6.00 PM then prints “Good After Noon Anirban” else if the system time is greater than 6.00 PM but less than 8.00 PM then “Good Evening Anirban” else if the system time is greater than 8.00 PM but less than 12.00 PM then “Good Night Anirban”).
  • 5. 5 Shell Script Output 9. Write a shell script that will receive a text filename(which contents a paragraph) interactively from the user during execution and prints the following according to the number of words present in the file: SHORT FILE(if the number of words is less than 100), MEDIUM FILE(if the number of words is greater than 100 but less than 350) , LARGE FILE( words greater than 350 but less than 500) and VERY LARGE FILE(words greater than 500). Shell Script
  • 6. 6 Output 10.Write a shell script that will receive a text filename as input and prints OFFICIAL FILE if the first line of the file contains the string “KGEC” only else prints UNOFFICIAL FILE. If the file is an OFFICIAL FILE then the program will prints number of words and characters present in the first 10 lines, it also appends string “Accessed on: <current date-time stamp>” at the end of the file. Shell Script Output 11.Write a shell script (check_exam.sh) that will use a file “exam_schedule.txt” to check whether there is any exam today or not. If there is no exam today then it will print: NO
  • 7. 7 EXAM TODAY. The file “exam_schedule.txt” must contain three fields as EXAM DATE(dd/mm/yyyy), EXAM TIME and EXAM PAPER. For example: 03/02/2014 10.00AM OPTICAL_NETWORK 04/02/2014 10.00AM IMAGE_PROCESSING ……… ……….. …………….. Shell Script Output 12.Write a shell script that will take the basic salary (BS) as runtime input from the user and calculates the DA (5% if BS is less than or equal to 10,000, above 10,000 it becomes 15%), HRA(5% if BS is less than or equal to 10,000, above 10,000 it becomes 7%) and finally calculates the gross salary(gross salary=BS+DA+HRA).
  • 8. 8 Shell Script Output 13.Write a shell script to display the following menu: i. Length of the string ii. Reverse of the string iii. Copy one string to another. Shell Script echo "Enter a string: " read str echo "i. Length of string" echo "ii.Reverse of the string" echo "iii. copy one string into another." echo "Enter your choice: " read c case "$c" in i)x=`echo $str | wc -c` x=`expr $x - 1` echo "Length is : $x";; ii)x=`echo $str | wc -c` x=`expr $x - 1` while [ $x -gt 0 ] do c=`echo $str | cut -c $x` s=$s$c x=`expr $x - 1` done echo "The Reverse of string is : $s";; iii)s=$str echo "The copied string is : $s";; esac
  • 9. 9 Output 14.Write a shell script to check whether a given number is prime or not. Shell Script echo "Enter a number: " read num i=2 f=0 while [ $i -le `expr $num / 2` ] do if [ `expr $num % $i` -eq 0 ] then f=1 fi i=`expr $i + 1` done if [ $f -eq 1 ] then echo "The number is composite" else echo "The number is Prime" fi Output 15.Write a shell script to check whether a given number is an Armstrong number or not. Shell Script echo "Enter a number: " read c x=$c sum=0 r=0 n=0 while [ $x -gt 0 ] do r=`expr $x % 10` n=`expr $r * $r * $r` sum=`expr $sum + $n` x=`expr $x / 10` done if [ $sum -eq $c ] then echo "It is an Armstrong Number."
  • 10. 10 else echo "It is not an Armstrong Number." fi Output 16.Write a shell script to find the sum of the first n numbers. Shell Script echo "Enter a number: " read num i=1 sum=0 while [ $i -le $num ] do sum=`expr $sum + $i` i=`expr $i + 1` done echo "The sum of first $num numbers is: $sum" Output 17.Write a shell script to find a sum of given no and to check out to see if it is even or odd. Shell Script echo "Enter a number: " read n sum=0 x=$n r=0 while [ $x -gt 0 ] do r=`expr $x % 10` sum=`expr $sum + $r` x=`expr $x / 10` done if [ `expr $sum % 2` -eq 0 ] then echo "The sum of $n is $sum and it is even" else echo "The sum of $n is $sum and it is odd" fi
  • 11. 11 Output 18.Write a shell script to find a factorial of a given number. Shell Script fact=1 ie=1 echo -e "Enter a number:c" read a while [ $ie -le $a ] do fact=`expr $fact * $ie` ie=`expr $ie + 1` done echo -e "Multilpication of $a number is $fact." Output 19.Write a shell script that takes 2 numbers through K/B and finds the value of first number raised to the power of second. Shell Script echo "Enter a number: " read a echo "Enter Power: " read p i=1 ans=1 while [ $i -le $p ] do ans=`expr $ans * $a` i=`expr $i + 1` done echo "Answer of $a^$p is $ans" Output 20.Write a shell script to read a string through keyboard and check whether it is palindrome or not. Shell Script echo "Enter a string: "
  • 12. 12 read s len=`echo $s | wc -c` while [ $len -gt 0 ] do st=`echo $s | cut -c $len` str=$str$st len=`expr $len - 1` done if [ $str = $s ] then echo "String Palindrome" else echo "string is not palindrome" fi Output