Assignments on Shell Programming
1. Basic salary of an employee is input through the keyboard. His DA is 48% of basic, HRA
is 15% of basic, Medical allowance Rs.300/-, ST Rs.40/-, GPF is 5% of basic and IT 10%,
of gross salary. Write a program to calculate his gross salary and net salary.
2. The length & breadth of a rectangle and radius of a circle are input through the keyboard.
Write a program to calculate the area & perimeter of the rectangle and the area &
circumference of the circle.
3. The three sides of a triangle are given through the keyboard. Write program to calculate
the area and perimeter of the triangle. Also check whether it is possible to construct a
triangle with the input provided.
4. Calculate the area of a trapezoid by taking necessary input from the keyboard.
5. Write a shell script which receives any year from the keyboard and determines whether
the year is a leap year or not. If no argument is supplied the current year should be
assumed.
6. An integer is input through the keyboard. Write a program to find out whether it is an odd
number or even number.
7. If cost price and selling price of an item is input through the keyboard, write a program to
determine whether the seller has made profit or incurred loss. Also determine how much
profit was made or loss incurred in terms of percentage.
8. Write a shell script to construct a shellcalculator that can perform addition, subtraction,
multiplication and division. (use switch case statement)
9. Write a shell script which receives two filenames as arguments. It should check whether
the two file's contents are same or not. If they are same then second file shouldbe deleted.
(Hint: Use the cmp command to compare files).
10. Write a shell program that will input the range (n) through command line and print all the
prime numbers within that range (starting from 0).
11. Write a shell script which gets executed the moment the user logs in. It should display the
massage "GoodMorning"/"GoodAfternoon""GoodEvening" depending upon the time at
which the user logs in.
12. a) Create a phone book with name and phone number of 10 persons using command line.
b) Search for a record in the file whether the name of the person is present or not, the
name of the person whose name to be found out will be supplied through command line.
b) Delete a record from the file, the name of the person whose name to be deleted will be
Supplied through command line.
13. Write ashell script that accepts one or more filenames as argument and convert all of
them to uppercase, provided they exists in the current directory.
14.Write a shell script that counts the number of directories under the current directory. And
also counts the files whose size is greater than 200 bytes.
15. Write ashell seript that accepts a filename as argument and displays its creation time, if
the tile eXists and if it does not exist, write an appropriate message. Also print whether the
existing file is readable, writable or executable.
16. Write a shellseript to find the smallest of three numbers that are read from the keyboard.
17. Write a program to find the value of one number raised to the power of another. The
numbers are entered through the keyboard.
18. Write a program to find the factorial value of any number entered through the command
line.
19. Write a shell program to check if someone is logged on or not using command line.
20. Write a shellprogram to check whether a number is palindrome or not.