![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sh -help with case statement (should be simple) | kuliksco | Shell Programming and Scripting | 1 | 11-19-2007 10:04 PM |
| case statement | bkan77 | Shell Programming and Scripting | 5 | 09-11-2007 06:54 PM |
| with Regard to Case Statement | cosec | Shell Programming and Scripting | 4 | 09-04-2007 03:15 AM |
| Case Statement | Zeta_Acosta | Shell Programming and Scripting | 19 | 04-06-2004 05:16 PM |
| case statement | Bab00shka | Shell Programming and Scripting | 1 | 07-15-2002 06:31 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I want to do this: Code:
Ex 1: case $answer in 1|2|3|4|5) echo $answer;; x) break;; *) echo "Invalid selection. Try again.";; esac But I need the part "1|2|3|4|5" to be fetched from a variable, like so: Code:
Ex 2: case $answer in $cases) echo $answer;; x) break;; *) echo "Invalid selection. Try again.";; esac So if the input is 1-n, I want my program to execute (its not really echo I plan on executing, but I will send $answer as the action's input). Is that possible? What I really want to know is, can the number of cases be variable depending on when the script is run? If so, how do I achieve it? When written like in ex 2 my input is interpreted as * every time. I have also tried replacing "$cases" with "´echo $cases´" with the same result. The script is written in bash and runs on Sun Solaris 9. Last edited by fialia; 05-09-2008 at 12:08 PM.. Reason: Icon is wrong |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|