echo "TO STUDY COMMAND LINE ARGUMENTS"
case $2 in
+) echo "Addition Operation"
x=$1
y=$3
echo "$x+$y=`expr $x + $y`" ;;
-) echo "Subtraction Operation"
x=$1
y=$3
echo "$x-$y=`expr $x - $y`" ;;
\*) echo "Multiplication Operation"
x=$1
y=$3
echo "$x*$y=`expr $x \* $y`" ;;
/) echo "Division Operation"
x=$1
y=$3
echo "$x/$y=`expr $x / $y`" ;;
esac
#OUTPUT:
#chmod +x cmd.sh
#./cmd.sh 2 + 3
#Addition Operation
#2+3=5
No comments:
Post a Comment