I'm trying to run a very simple script that reads input from a user and continuously loop a question if the users input doesn't match what is expected.
It's being execute via bash:
echo "Specify a directory [Y/N]?"
read ans
while [ [ "$ans" != "Y" ] || [ "$ans" != "y" ] || [ "$ans" != "N" ] || [ "$ans" != "n" ] ]
do
echo "$ans is not valid, please answer [Y/N]"
read ans
done
code continues....
Any idea why this is not working? It seems like a pretty straight forward loop.
[...]expressions inside each other.(and)instead (possibly with appropriate escaping/quoting, depending on your exact syntax).