The easiest thing to do is loop forever and break when a user exits:
while true do read -p "Continue to loop? " answer [ "n" = "$answer" ] && break done echo "Now I'm here!"
The break command breaks you out of the current loop and continues immediately after the loop. There is no need for a flag variable.
By the way:
[ "n" = "$answer" ] && break
Same as:
if [ "n" = "$answer" ] then break fi
Note -p for a prompt in the read command. This way you can query and read the variable at the same time. You can also use \c in echo statements to suppress a new line, or use printf , which does not execute NL:
read -p "What do you want? " wants
Hope this helps.
source share