I'm new to bash, and the below while loop is driving me crazy. I want the loop to exit when the user enters y or n but it fails to do so. I have tried different ways but no luck. Anyone can point me in the right direction?
echo "want to go for a walk Y/N "
read answer
while [ "$answer" != "y" ] || [ "$answer" != "n" ] ; do
echo "Enter y or n"
read answer
done
The second solution also is in the same scenario
echo "want to go for a walk Y/N "
read answer
while [ "$answer" != "y" || "$answer" != "n" ] ; do
echo "Enter y or n"
read answer
done