I'm trying to have the script exit if the user enters 'q'
here's the code:
echo "Enter Choice => "
read target
if [[ $target=='q' ]]; then
exit 1
else
#do something
fi
However when I run it no matter what the input is, the script exits...
I'm trying to have the script exit if the user enters 'q'
here's the code:
echo "Enter Choice => "
read target
if [[ $target=='q' ]]; then
exit 1
else
#do something
fi
However when I run it no matter what the input is, the script exits...
#!/bin/bash
echo "Enter Choice => "
read target
if [[ $target == 'q' ]]; then
exit 1
else
#do something
echo "do something..."
fi
~
Try this - spacing between the tokens $target, '==' and 'q' is important.