Professional Documents
Culture Documents
ZZ Shell Script Record
ZZ Shell Script Record
1. Area and Perimeter of a Circle
Aim : Write a shell script to find the area and perimeter of a circle
Output :
2. Menu driven Calculator
Aim : Write a shell script to make a menu driven calculator using case
Output :
3. Largest of three numbers
Aim : Write a shell script to find the greatest of three numbers
Output :
4. Mean and Standard Deviation
Aim : Write a shell script to compute mean and standard deviation of three numbers
Output :
5. Reverse a Number and Sum of digits
Aim : Write a shell script to find reverse of a number
Output :
6. List n Fibonacci numbers
Aim : Write a shell script to find n fibonacci numbers
Output :
7. Check whether a number is Armstrong or not
Aim : Write a shell script to check whether a given number is Armstrong or not
Output :
8. Factorial of a Number
Aim : Write a shell script find the factorial of a given number
Output :
9. List Prime numbers upto a given number
Aim : Write a shell script to find prime numbers up to a given number
Output :
10. Reverse a String and Check whether Palindrome or not
Aim : Write a shell script to reverse a string and check whether a given string is palindrome or not
Output :
11. Number of lines, words and characters in a file
Aim : Write a shell script to count no of line, words and characters of a input file
Output :
12. Calculate Gross Salary
Aim : An employee Basic salary is input through keyboard where da is 40% of basic salary and hra is
20% of basic salary. Write a shell script to calculate gross salary
Output :
13. Average of numbers – command line arguments
Aim : Write a shell script to find the average of the number entered as command line arguments
Output :
14. Greeting Message depending on current time
Aim : Write a Shell script which whenever gets executed displays the message “Good Morning/Good
afternoon /Good Evening “ depending on the time it get executed"
Output :
15. File test operators
Aim : Write a shell script which uses all the file test operators
16. Count Vowels, Consonants, Numbers in a string
Aim : Write a shell script to find number of vowels, consonants, numbers in a given string.
Output :
17. Phonebook – add/display/search/delete
Aim : Write a shell script to create a file phonebook and do the following,
add name and phonenumber, display all records, search for a record, delete a record
ch=0
FILE="phonebook.txt"
while [ $ch -le 3 ]
do
echo "Phone book - Add/Search/Display"
echo "1:ADD NEW RECORD 2:DISPLAY 3:SEARCH 4: EXIT"
echo -n "Enter your choice : "
read ch
case $ch in
1) echo -n "Enter name : "
read nm
echo -n "Enter phone no : "
read pn
echo "$nm $pn" >> phonebook.txt
;;
2) echo "Contents of PHONE BOOK :"
cat $FILE
;;
3) echo -n "Enter name to search : "
read nam
phn=`grep $nam $FILE | cut -f2 -d" "`
if [ "$phn" != "" ]
then
echo "Phone no of '$nam' is '$phn'"
else
echo "Name '$nam' is not found in phone book"
fi
;;
4) break;
;;
*) echo "invalid choice!!"
;;
esac
echo ""
done
18. Compute and display Grade based on marks
Aim : Write a shell script to accept student number, name, marks in 5 subjects. Find total, average and
grade.
Rules: avg>=90 then grade A
Avg<90 && Avg>=80 then grade B
Avg<80 && Avg>=60 then grade C
Avg<60 && Avg>=40 then grade D
Avg<40 then grade E
19. Sort Numbers in ascending order
Aim : Write a shell script to read 10 numbers in a array and sort the number in ascending order
Output :
20. System/Login Details
Aim : Write a shell script to display current date and time, number of users, terminal name, login date
and time
Output :