using switch on multiple arguments


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using switch on multiple arguments
# 1  
Old 04-13-2011
using switch on multiple arguments

I have a switch statement, and I want to have two options performing the same thing. For example, if $opt matches "-fb" or "--fbase", I want to perform the same operation. How can I include various matches in "case" ?

Code:
  switch ($opt)

  case "-T":
    set Atpath = $par
    set opt_tpath = 1
     breaksw

  case "-fb":
    set Afbase = $par
    set opt_fbase = 1
    breaksw

# 2  
Old 04-13-2011
case "-fb"|"--fbase":
# 3  
Old 04-13-2011
Are the quotes important, or can I go without

Code:
case -fb|--fbase:

# 4  
Old 04-13-2011
Ooops sry i did a mix

---------- Post updated at 02:29 AM ---------- Previous update was at 02:26 AM ----------

Have a look at this
case (Learning the Korn Shell, 2nd Edition)
# 5  
Old 04-13-2011
Yes, does not take it.
# 6  
Old 04-13-2011
Please post your code and the manner it which it misbehaved.
# 7  
Old 04-13-2011
I am referring to csh. Had a look at ksh, they don't mention having multiple matches either.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep multiple words in a file with help of fixed string switch

I have multiple strings in a file which have special character $, when i search strings by ignoring $ with \ using single quotes it returns empty results. My search strings are set char_1($lock) and set new_char_clear_3($unlock) I tried searching with but it returns empty results.However... (3 Replies)
Discussion started by: g_eashwar
3 Replies

2. Shell Programming and Scripting

Passing multiple arguments

Hi, I know with getopts you can pass arguments from the command line ./script -ab -c apple But it doesn't support 2 or more arguments for ONE option. Is there any other way to do this? Thanks (2 Replies)
Discussion started by: testa500
2 Replies

3. Programming

Passing arguments from command line to switch case statement in C

Hi Am pretty new to C.. Am trying to pass the arguments from command line and use them in switch case statement.. i have tried the following #include <stdlib.h> main(int argc, char* argv) { int num=0; if ( argc == 2 ) num = argv; printf("%d is the num value",num); switch ( num ) ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

4. Shell Programming and Scripting

Multiple runtime arguments

I am passing 3 runtime arguments to a shell script $path crtl1 crtl2 the crtl files contains data(filename|date|count) filename.txt|02/05/2010|10 The path contains the original data file,the code should fetch (filename|date|count) from original data file and it should match... (7 Replies)
Discussion started by: Prashanth B
7 Replies

5. Shell Programming and Scripting

Multiple arguments to read

I am developing a script where 3 other scripts are included. This is a graph related script. COMPLETE IDEA: -There are 3 different graph scripts. I would like to create a master graph with all 3 in one. -User chooses the type of graph -User is asked to enter the required auguments (... (7 Replies)
Discussion started by: newkid.7955
7 Replies

6. Shell Programming and Scripting

Two arguments for optional switch

How to declare the two argument for optional switch ? I have a script that search for a string in current or old zipped log file. Im using a option something like this ${basename} Since $1 can have only one argument should be passed when user select swicth -c and -o need to... (3 Replies)
Discussion started by: baraghun
3 Replies

7. Shell Programming and Scripting

using multiple arguments in my script

hi all i am creating a script to ping hosts and then do a nslookup. So what needs to happen is that i type the script name with an argument eg: zong (script name) 172.x.x.x (IP) at the moment i have got it to take on argument, but idealy i would like it to take more than 1 argument. can you... (1 Reply)
Discussion started by: brian112
1 Replies

8. Shell Programming and Scripting

How do we pass multiple arguments into awk

How do we pass multiple arguments into awk : name=john age=12 now i have to pass both age and name into awk.. how to do it? like : awk -v var=... (4 Replies)
Discussion started by: abhinav192
4 Replies

9. Shell Programming and Scripting

Grepping multiple terms with different arguments

Grep -e 'term1' -A1 -e 'term2' -A3The above code always searches for either term and prints results + next three lines. I'm trying to print out: foo foo foo term1 bar bar bar line right after the above -- la la la la term2 so so so line right after the above and again and again I've... (7 Replies)
Discussion started by: dkozel
7 Replies

10. Shell Programming and Scripting

can't TEST multiple arguments for a file

Hi, I'm new to scripting and teaching myself how to code. Using Korn, I coded this one return "True" if a file is executable and it's not empty. However, each time I pass a file that is 777 which contains data, the script returns "false". if then echo "true" else echo... (2 Replies)
Discussion started by: cruiser
2 Replies
Login or Register to Ask a Question