I'm trying to write a bash script that asks if a person wants a cup of tea, with Y returning “Great, I’ll make tea now” to the console"; and N returning “Are you sure” 4 more times before stopping the loop. Also if during the 4 follow up offers, the user changes their mind and presses ‘Y’, the computer will print out “Great, I’ll make tea now” to the console.
My script below results in an infinite loop, so I need some increment count in the code and I just cant figure out where? Possibly a very basic question and if so apologies, new to Linux Bash scripting, any help appreciated:
#!bin/bash
#tea2.sh
echo "Will you have a cup of tea?"
read answer
while [ "$answer" = n ]
do
echo "Are you sure"
if [ "$answer" = y ]
then
break
fi
echo "Great, I\’ll make tea now"
done
second script:
#!/bin/bash
#tea3.sh
set yname="Would you like a cup of tea?"
while ($yname != "n")
echo -n "Are you sure?"
set yname = $<5
if ($yname != "y") then
echo "Great, I\'ll make tea now"
fi
done