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

What's hot

systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in cMeghna Roy
 
Modern OpenGL scientific visualization
Modern OpenGL scientific visualizationModern OpenGL scientific visualization
Modern OpenGL scientific visualization
Nicolas Rougier
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Maximum sum subarray
Maximum sum subarrayMaximum sum subarray
Maximum sum subarray
Shaheen kousar
 
3. cs8451 daa anna univ question bank unit 3
3. cs8451 daa anna univ question bank unit 33. cs8451 daa anna univ question bank unit 3
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
Nithin Kumar,VVCE, Mysuru
 
Introduction to Rust
Introduction to RustIntroduction to Rust
Introduction to Rust
Jean Carlo Machado
 
Introduction to toc and compiler
Introduction to toc and compilerIntroduction to toc and compiler
Introduction to toc and compiler
savitamhaske
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
Faraz Ahmed
 
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime modulePython Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime module
P3 InfoTech Solutions Pvt. Ltd.
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
Intro C# Book
 
DATABASE MANAGEMENT SYSTEM LAB.pdf
DATABASE MANAGEMENT SYSTEM LAB.pdfDATABASE MANAGEMENT SYSTEM LAB.pdf
DATABASE MANAGEMENT SYSTEM LAB.pdf
Prof. Dr. K. Adisesha
 
Celery
CeleryCelery
Celery
Fatih Erikli
 
Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)
SHAMJITH KM
 
Python sqlite3
Python sqlite3Python sqlite3
Python sqlite3
Alexey Bovanenko
 
asymptotic notation
asymptotic notationasymptotic notation
asymptotic notation
SangeethaSasi1
 
C++ STL
C++ STLC++ STL
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
kamesh dagia
 
Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3ahmed22dg
 

What's hot (20)

systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in c
 
Modern OpenGL scientific visualization
Modern OpenGL scientific visualizationModern OpenGL scientific visualization
Modern OpenGL scientific visualization
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Maximum sum subarray
Maximum sum subarrayMaximum sum subarray
Maximum sum subarray
 
3. cs8451 daa anna univ question bank unit 3
3. cs8451 daa anna univ question bank unit 33. cs8451 daa anna univ question bank unit 3
3. cs8451 daa anna univ question bank unit 3
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
 
Introduction to Rust
Introduction to RustIntroduction to Rust
Introduction to Rust
 
Introduction to toc and compiler
Introduction to toc and compilerIntroduction to toc and compiler
Introduction to toc and compiler
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime modulePython Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime module
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
 
DATABASE MANAGEMENT SYSTEM LAB.pdf
DATABASE MANAGEMENT SYSTEM LAB.pdfDATABASE MANAGEMENT SYSTEM LAB.pdf
DATABASE MANAGEMENT SYSTEM LAB.pdf
 
Celery
CeleryCelery
Celery
 
Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)
 
Python sqlite3
Python sqlite3Python sqlite3
Python sqlite3
 
asymptotic notation
asymptotic notationasymptotic notation
asymptotic notation
 
C++ STL
C++ STLC++ STL
C++ STL
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
 
Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3
 

Similar to Solution manual of shell programming assignment 2

Shell programming assignment 2
Shell programming assignment 2Shell programming assignment 2
Shell programming assignment 2
Kuntal Bhowmick
 
What is a shell script
What is a shell scriptWhat is a shell script
What is a shell script
Dr.M.Karthika parthasarathy
 
Shell programming
Shell programmingShell programming
Shell programming
Moayad Moawiah
 
The Korn Shell is the UNIX shell (command execution program, often c.docx
The Korn Shell is the UNIX shell (command execution program, often c.docxThe Korn Shell is the UNIX shell (command execution program, often c.docx
The Korn Shell is the UNIX shell (command execution program, often c.docx
SUBHI7
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programmingkayalkarnan
 
ShellProgramming and Script in operating system
ShellProgramming and Script in operating systemShellProgramming and Script in operating system
ShellProgramming and Script in operating system
vinitasharma749430
 
null Pune meet - Application Security: Code injection
null Pune meet - Application Security: Code injectionnull Pune meet - Application Security: Code injection
null Pune meet - Application Security: Code injection
n|u - The Open Security Community
 
Linux Lab Manual.doc
Linux Lab Manual.docLinux Lab Manual.doc
Linux Lab Manual.doc
Dr.M.Karthika parthasarathy
 
Shell Programming_Module2_Part2.pptx.pdf
Shell Programming_Module2_Part2.pptx.pdfShell Programming_Module2_Part2.pptx.pdf
Shell Programming_Module2_Part2.pptx.pdf
HIMANKMISHRA2
 
The best unix shell scripting interview questions 2018 learn now!
The best unix shell scripting interview questions 2018   learn now!The best unix shell scripting interview questions 2018   learn now!
The best unix shell scripting interview questions 2018 learn now!
mia avery
 
First steps in C-Shell
First steps in C-ShellFirst steps in C-Shell
First steps in C-Shell
Brahma Killampalli
 
Loops (Refined).pptx
Loops (Refined).pptxLoops (Refined).pptx
Loops (Refined).pptx
chimkwuogworordu
 
Unix lab
Unix labUnix lab
Wildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell VariablesWildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell Variables
Gaurav Bisht
 
Powershell notes
Powershell notesPowershell notes
Powershell notes
Carlos Amorim
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
mugeshmsd5
 
Php introduction
Php introductionPhp introduction
Php introduction
Osama Ghandour Geris
 

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

Shell programming assignment 2
Shell programming assignment 2Shell programming assignment 2
Shell programming assignment 2
 
What is a shell script
What is a shell scriptWhat is a shell script
What is a shell script
 
Shell programming
Shell programmingShell programming
Shell programming
 
The Korn Shell is the UNIX shell (command execution program, often c.docx
The Korn Shell is the UNIX shell (command execution program, often c.docxThe Korn Shell is the UNIX shell (command execution program, often c.docx
The Korn Shell is the UNIX shell (command execution program, often c.docx
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
 
ShellProgramming and Script in operating system
ShellProgramming and Script in operating systemShellProgramming and Script in operating system
ShellProgramming and Script in operating system
 
null Pune meet - Application Security: Code injection
null Pune meet - Application Security: Code injectionnull Pune meet - Application Security: Code injection
null Pune meet - Application Security: Code injection
 
Linux Lab Manual.doc
Linux Lab Manual.docLinux Lab Manual.doc
Linux Lab Manual.doc
 
Shell Programming_Module2_Part2.pptx.pdf
Shell Programming_Module2_Part2.pptx.pdfShell Programming_Module2_Part2.pptx.pdf
Shell Programming_Module2_Part2.pptx.pdf
 
The best unix shell scripting interview questions 2018 learn now!
The best unix shell scripting interview questions 2018   learn now!The best unix shell scripting interview questions 2018   learn now!
The best unix shell scripting interview questions 2018 learn now!
 
First steps in C-Shell
First steps in C-ShellFirst steps in C-Shell
First steps in C-Shell
 
Loops (Refined).pptx
Loops (Refined).pptxLoops (Refined).pptx
Loops (Refined).pptx
 
Unix lab
Unix labUnix lab
Unix lab
 
Wildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell VariablesWildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell Variables
 
Slides
SlidesSlides
Slides
 
Powershell notes
Powershell notesPowershell notes
Powershell notes
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
 
Php introduction
Php introductionPhp introduction
Php introduction
 
lab4_php
lab4_phplab4_php
lab4_php
 
lab4_php
lab4_phplab4_php
lab4_php
 

More from Kuntal Bhowmick

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

More from Kuntal Bhowmick (20)

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

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 

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