UNIX and Shell Programming
Assignment 8 : Shell Scripting
1. Write a shell script that prints “Shell Scripting is Fun!” on the screen. Modify the
shell script above to include a variable. The variable will hold the contents of the
message “Shell Scripting is Fun!”.
2. Print the values of the environment variables HOME, USER, SHELL and PATH
with set, print env and echo.
3. Store the output of the command “hostname” in a variable. Display “This script is
running on _.” where “_” is the output of the “hostname” command.
4. Get two numbers a and b from user using read statement. Do the following:
a. Add the two numbers
b. Subtract the numbers
c. Multiply the numbers
d. Divide the numbers
Print the result.
5. Get length and breadth for a rectangle and radius for a circle using command line
argument. Calculate area and perimeter of the rectangle and also area and
circumference of a circle. Use the special character data types and display the
arguments using them.
6. Temperature of a city in Fahrenheit degree is input through the keyboard. Write
a program to convert this temperature into Centigrade degrees.
Formula is
c = (f - 32)*5 /9
f=9/5*c+32
7. Write a shell script to implement the propery of special variable using command
line argument.
8. Write a shell script to declare an array with fruits as elements. Print the
following.
a. Print the elements at first and last index
b. Print all elements in the array.
c. Number of elements in the array
9. Write a shell script to create array of elements using command line arugment.