samedi 19 juin 2021

I can not get my if statement to work. Learning to code bash and have researched but can't see the error

I am very new to bash scripting and always having issues with if/else statements.

In this case I am trying to call the $virus variable which is in a case statement ( I am studying CyberSec)

esac
sleep 2

read -p "Would you like to learn about another virus? yes/no :  " y
if [ $y = "yes" ]; then 
echo "$virus";
else echo -e "Good-bye";
fi

exit

The else part works fine. if 'yes' is entered the script recalls the number I entered in the question I made "What irus would you like to learn about" there is five selection 1 - 5 to choose from.

Confusing I guess. I simply want the information in the case statement to display when the user answers yes.

Aucun commentaire:

Enregistrer un commentaire