How do you exit a while loop in bash when user input detects "done"?
The objective is to have users input restaurant names and when they type done, the while loop escapes and and it randomly spits out a random restaurant within the array? As of right now, it only escapes when CTRL + D but this also closes the terminal
P.S: I've only been playing with bash for about 2 hours!
echo 'Where are you having trouble deciding? Type done to finish'
while read restaurants
do
rest_array=("${rest_array[@]}" $restaurants)
done
echo Eat at ${rest_array[$rand]}
breakcommand to exit any loop.rest_array+=("$restaurants")is a simpler way to append to the array.