Im facing following problem I have created mentioned condition, but when I choose y for yes everything is ok, but when I choose n for not I get annoying error output:
output :
Do you agree yes (y) or not (n)
n
./myscript: [n: command not found
myscript is the name of my script
Code here:
echo "Do you agree yes (y) or not (n)"
read answer
if ( [ "$answer" = 'y' ] || ["$answer" = 'Y' ]);
then
echo -e “ output for y”
done
else
echo -e " output for n "
exit 1;
Any idea how can I get rid of the output and fix the problem ?
thanks
That’s not bash. “done” does not terminate an “if” condition in bash. You should remove “done” and add “fi” at the end of the else body.
Also, the semicolon after “exit 1” is not needed.