M.Tech Practical List
M.Tech Practical List
List of Program:
Prog 9: Write a shell program to find the average of students marks using for loop and
while loop.
Prog10: Write a shell script to compute all arithmetic operations on which are given by
user.
Prog 11: Write a shell program to find the average of students marks using for loop and
while loop.
Prog14: Write a shell script that accepts a file name starting and line number as
arguments and display all line.
Prog15: Write a shell script to print months of a year using switch case.
Prog16: Write a shell script that accept two integers as its argument and computes the
value of first number raised to the power of the second number.
Write a shell script that accepts a file name starting and ending numbers as Arguments and
displays all the lines between the given line numbers.
Shell Script
#!/bin/csh
--------------------------------------------------------------
Write a shell script that accepts two integers as its arguments and computes the value of first
number raised to the power of the second number.
Shell Script
#!/bin/csh
set c = 1
set result = 1
@ result *= $argv[1]
@ c = $c + 1
end
--------------------------------------------------------------
Write a shell program to convert temperature in centigrade to Fahrenheit.
Shell Script
# formula Tf=(9/5)*Tc+32
# formula Tc=(5/9)*(Tf-32)
tc=$(echo "scale=2;(5/9)*($tf-32)"|bc)
echo "$tf = $tc"
else
echo "Please select 1 or 2 only"
exit 1
fi
--------------------------------------------------------------
Write a shell program to find the average of students’ marks
Shell Script
for i in $*
do
temp_total=`expr $temp_total + $i`
done
avg=`expr $temp_total / $number_of_args`
echo "Average of all marks is $avg"
--------------------------------------------------------------
Shell Script
--------------------------------------------------------------
Write a shell script to compute all arithmetic operations on which are given by user.
Shell Script
if [ $# -lt 3 ]
then
echo "$0 num1 opr num2"
echo "opr can be +, -, / , x"
exit 1
fi
case "$op" in
+) echo $(( $a + $b ));;
-) echo $(( $a - $b ));;
/) echo $(( $a / $b ));;
x) echo $(( $a * $b ));;
*) echo "Error ";;
esac
--------------------------------------------------------------
Write a shell script that accepts two integers as its arguments and computes the value of first
number raised to the power of the second number.
Shell Script
#!/bin/csh
set c = 1
set result = 1
@ result *= $argv[1]
@ c = $c + 1
end