LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-11-2010, 09:06 PM   #1
jdwalk
LQ Newbie
 
Registered: Feb 2010
Posts: 9

Rep: Reputation: 0
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
 
Old 02-11-2010, 09:28 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
"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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off




All times are GMT -5. The time now is 03:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration