Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

If condition - else is never executed

$
0
0
In the following code snippet, 'if' part is always executed irrespective of whether I enter 'y' or 'n'. I am unable to figure out my mistake even after spending couple of hours. Can someone point out the mistake? Thank you!

Code:

echo "Do you want to delete?(y/n):"
read USERINPUT
echo $USERINPUT

if [ $USERINPUT="y" ]
then
        echo "Deleted."
elif [ $USERINPUT="n" ]
then
        echo "Not deleted."
fi


Viewing all articles
Browse latest Browse all 16232

Trending Articles