Skip to content

Instantly share code, notes, and snippets.

@larien
Created August 30, 2020 19:56
Show Gist options
  • Save larien/80d3407972f46a08c0e8a11a0d1271a6 to your computer and use it in GitHub Desktop.
Save larien/80d3407972f46a08c0e8a11a0d1271a6 to your computer and use it in GitHub Desktop.
# !/bin/bash
echo "Insira dois números: "
read a
read b
echo "Escolha a operação:"
echo "1. +"
echo "2. -"
echo "3. *"
echo "4. /"
read ch
if [ $ch -eq "1" ]
then
res=`echo $a + $b | bc`
elif [ $ch -eq "2" ]
then
res=`echo $a - $b | bc`
elif [ $ch -eq "3" ]
then
res=`echo $a \* $b | bc`
elif [ $ch -eq "4" ]
then
res=`echo "scale=2; $a / $b" | bc`
else
echo "comando inválido"
fi
echo "Resultado : $res"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment