Я пытаюсь создать калькулятор геометрических фигур, и я застрял в цикле.Я использую меню в сценарии оболочки, и пока что мне не повезло.
Может кто-нибудь помочь мне с этим?
Текущий сценарий:
#!/bin/bash
echo "Welcome, please enter username:"
read $username
echo "WELCOME $( getent passwd "$USER" | cut -d: -f5 | cut -d, -f1), This is a basic calculator of square,circle and rectangle. "
echo "Please choose from 1,2 or 3 to continue: "
echo "1. Rectangle"
echo "2. Circle"
echo "3. Square"
echo "4. Quit"
read choice
if [ $choice -eq 1 ]
then
echo "You choose rectangle"
echo "Enter the height:"
read height
echo "Enter the width:"
read width
area=`echo "$height * $width"|bc`
echo "The area of the rectangle is:"$area
else
if [ $choice -eq 2 ]
then
echo "You choose circle"
echo "Enter the radius of the circle:"
read radius
area1=`echo "3.141 * $radius * $radius"|bc`
echo "The area of the circle is:"$area1
else
if [ $choice -eq 3 ]
then
echo "You choose square"
echo "Enter the width of the square:"
read w
area2=`echo "$w * $w"|bc`
echo "The area of the circle is:"$area2
else
If [ $choice -eq 4 ]
then "You choose quit"
"Quit")
break
;;
*) echo invalid option;;
Как вывидите, я понятия не имею, как остановить цикл и "выйти".
Спасибо!