LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-13-2011, 05:59 PM   #1
Icewolf0927
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Rep: Reputation: 0
Case Statement Command not found


Hi
I have a case statement that works but I am getting command not found before it displays my echo statements and I am just wondering why it would do that.
Here is my code.
Code:
read -p  "What month is it?" month

 $month

case $month in

"Janurary") echo " $month is Winter ";;
"Feburary") echo "$month  is Winter ";;
"March") echo " $month is Spring ";;
"April") echo " $month is Spring ";;
"May") echo " $month is Spring ";;
"June") echo " $month is Summer ";;
"July") echo " $month is Summer ";;
"August") echo " $month is Summer ";;
"September") echo " $month is Fall ";;
"October") echo " $month is Fall ";;
"November") echo " $month is Fall ";;
"December") echo " $month is Winter";;
*) echo " $month is not valid" ;;

esac

Here is what the output looks like
Code:
[Icewolf@Crazy ~]$ ./lab5case
What month is it?April
./lab5case: line 5: April: command not found
 April is Spring
Thanks
Andy
 
Old 08-13-2011, 06:29 PM   #2
roger_heslop
Member
 
Registered: Oct 2009
Location: Leander, TX
Distribution: Fedora 20
Posts: 97

Rep: Reputation: 35
I copied your script, just to make sure I was reading it right. Here's what I found...


read -p "What month is it?" month

$month <<<<<<<< Remove me

case $month in

"Janurary") echo " $month is Winter ";;
"Feburary") echo "$month is Winter ";;
"March") echo " $month is Spring ";;
"April") echo " $month is Spring ";;
"May") echo " $month is Spring ";;
"June") echo " $month is Summer ";;
"July") echo " $month is Summer ";;
"August") echo " $month is Summer ";;
"September") echo " $month is Fall ";;
"October") echo " $month is Fall ";;
"November") echo " $month is Fall ";;
"December") echo " $month is Winter";;
*) echo " $month is not valid" ;;

esac
 
1 members found this post helpful.
Old 08-13-2011, 06:45 PM   #3
Icewolf0927
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Original Poster
Rep: Reputation: 0
I knew it was something stupid lol. Thanks for you help
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl switch statement throwing error like Bad case statement (invalid case value?) kavil Programming 2 10-07-2010 04:50 AM
Case Statement craigjward Programming 6 12-12-2007 11:33 PM
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 08:05 PM
bash case statement with multiple command line options pwc101 Programming 16 06-01-2007 11:43 AM
case statement baks Programming 2 03-15-2007 01:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:16 PM.

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
Open Source Consulting | Domain Registration