![]() |
|
|||||||
| Home | Forums | Register | Rules & FAQ | Donate | Members List | 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 here. |
![]() |
|
|
Submit Tools | Thread Tools | Search this 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 Code:
Ex 2: case $answer in $cases) echo $answer;; x) break;; *) echo "Invalid selection. Try again.";; esac 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 : 1 Week Ago at 10:08 AM. Reason: Icon is wrong |
| Forum Sponsor |
|
|
|
|||
|
Try this
Quote:
|
| Forum Sponsor |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help needed in using case statement | jisha | Shell Programming and Scripting | 0 | 01-16-2008 02:33 AM |
| case statement | bkan77 | Shell Programming and Scripting | 5 | 09-11-2007 04:54 PM |
| with Regard to Case Statement | cosec | Shell Programming and Scripting | 4 | 09-04-2007 01:15 AM |
| Case Statement | Zeta_Acosta | Shell Programming and Scripting | 19 | 04-06-2004 03:16 PM |
| case statement | Bab00shka | Shell Programming and Scripting | 1 | 07-15-2002 04:31 AM |