Im writing a script that prompts the user to pick one of three choices, depending on the choice the prompt should echo back a line.
"!/bin/bash
first=chocolate
second=vanilla
third=strawberry
echo "Which would you choose?"
read -p "chocolate,vanilla or strawberry?"
if [ $first ];
then
echo "Chocolate! good choice"
else
echo "Not a valid choice"
if [ $second ];
then
echo "vanilla! good choice"
else
echo "Not a valid choice"
if [ $third ];
then
echo "Strawberry! good choice"
else
echo "Not a valid choice"
fi
But it doesnt work, I type in one of the choices in the prompt when it asks for it but I get back :line 28: syntax error: unexpected end of line
I dont know whats wrong, i have spacing between the brackets and I end the code with fi.