switch case : Perform Arithmetic operations in bash.

p9.sh

#!/bin/bash

echo  "Enter number a: "
read a
echo "Enter number b: "
read b

echo "Enter operation: "
read op
case "$op" in
"+")
echo $(($a + $b));;
"-")
echo $(($a - $b));;
"*")
echo $(($a * $b));;
"/")
echo $(($a / $b));;
esac

Post a Comment

Previous Post Next Post