While Loop Errors

I have the following chunk of code...

while [ $answer != X || $answer != x ]

when I try to execute this script, it outputs an error "test: ] missing"

Is there a syntax error here?

while [ "$answer" != "x" ] || [ "$answer" != "X" ]

..except that this is a logic error and will loop forever. One or the other conditions will always evaluate to true and keep the loop going.

Try && instead of ||

Even with substituting the || for &&, it gives me the same error message

test: ] missing

Please post your entire script, then.

Did you also notice the double quotes and the extra square brackets that Corona688 introduced?

answer=x
while [ $answer != X && $answer != x ]
do
echo "Phone Book"
echo "Phone Company"
echo "Company Number"
echo ""
echo ""
echo "A - Add a new line in the phone book"
echo "D - Delete a line from the phone book"
echo "M - Modify a line in the phone book"
echo "I - Inquire on a name in the phone book"
echo "X - Exit"
echo ""
echo ""
echo "What would you like to do? \c"
read answer
case $answer in

That's all i have so far...

Try the answer I actually gave you.

ok that worked. The purpose of my code is to repeat that menu until the user presses x or X. Now it is an infinite loop. I cannot figure out how to make it exit when the user presses X.

It's an infinite loop because of the other thing I told you.

codecode