LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   if...then....else? (https://www.linuxquestions.org/questions/linux-newbie-8/if-then-else-788570/)

jdwalk 02-11-2010 08:06 PM

if...then....else?
 
Not sure why this won't work, any thoughts?

echo enter the letter A or the letter B
read letter
if["$letter" = "A"]; then
echo "coolit's an A"
elif["$letter" = "B"]; then
echo "not cool it's a B"
else
echo "You MESSED UP!"
fi

jlinkels 02-11-2010 08:28 PM

"Won't work is broad", how doesn't it work?

There must be a space between 'if' and '['
Comparison might work with '=', yet it is clearer to use '=='
Run your script with 'sh -x <scriptname>

jlinkels


All times are GMT -5. The time now is 03:20 PM.