Case -- esac number of arguments problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Case -- esac number of arguments problem
# 1  
Old 03-07-2014
Wrench Case -- esac number of arguments problem

hi Scripting experts, I am using case..esac in my script .. I have given 6 option..e.g. 1 2 3 4 5 and *, howerver my script works welll for 1st 4 options but for 5 it considers * and exists. Is there a maximum limit on number of options given for case ..esac?
# 2  
Old 03-07-2014
Hello,

If you can show us the code it will good, but still please make sure you have put ;; at the end of each case.

Here is a rough exmple for same.

Code:
 case ${line}
in
                        1) echo "1st option";;
                        2) echo "2nd option";;
                        *) echo "Please select the appropriate option";;
esac


Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If number of arguments =$ or $

Hi, I am having a bit of trouble writing this. I have the script working if I only use 1 of these but it's not working the way i need it to. Basically more above the script i may or may not have a 5th variable defined. if i do it does a process before getting to the rest of the script.... (2 Replies)
Discussion started by: techy1
2 Replies

2. 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

3. Shell Programming and Scripting

case statement for different cmd arguments

Hello friends, I have a boubt passing different arguments at a time for any one option in below code. I would also like to check which option has been selected (any one of i, r, u ) so that whether or not matching argument passed can be verified. for i and r - install and re-install -... (4 Replies)
Discussion started by: pd2
4 Replies

4. Shell Programming and Scripting

[C SHELL] How to pass dynamic number of arguments

I have a task. The scenario is like this. I have a operation program (OPR1) , whose function is to simply double the (single)value it receives as input. I have to write a script to operate the OPR1 and save its output in a file. Later, I have to modify the script so as to be able to operate ... (0 Replies)
Discussion started by: animesharma
0 Replies

5. Shell Programming and Scripting

How to use case and command line arguments in shell script?

Hi... can anyone please help me out in using the CASE and command line argument in shell script... i am bit new to shell scripting...below i have explained my proble with example... say i have an executable file with name 'new1.sh' and there are 3 functions in it a(), b() and c()....and there... (5 Replies)
Discussion started by: swap21783
5 Replies

6. UNIX Desktop Questions & Answers

Specifying a range within case/esac

Complete Unix beginner here. I basically have this script - This seems to work fine. I want to try and shorten it by making it something like this - This isn't working. I think it's probably to do with the zero padding that `date +%H` gives me, but if I use `date +%k`, I get a space at... (3 Replies)
Discussion started by: Orbient
3 Replies

7. Homework & Coursework Questions

checking for number of arguments.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Your script must check for the correct number of arguments (one argument). If somebody tries to invoke the... (1 Reply)
Discussion started by: brooksie91
1 Replies

8. UNIX for Dummies Questions & Answers

how to break within a case/esac and stay in script

Wrote the following loop to but if I use exit, then I break entirely from my script, but instead I want to break from the case/esac and go to the next line in my script. I guess I need to know how to exit gracefully from a "while (true). Also, how can I allow the user to enter upper or lowercase... (4 Replies)
Discussion started by: tumblez
4 Replies

9. UNIX for Dummies Questions & Answers

maximum number of arguments

Hi, What is the maximum number of arguments that could be passed to zsh ? To find out that I tried a simple script. And the maximum number of arguments that could be passed turned out to be 23394 #! /bin/zsh arg=1 i=1 subIndex=23000 while do arg=$arg" "$i i=$(($i + 1))... (9 Replies)
Discussion started by: matrixmadhan
9 Replies

10. Shell Programming and Scripting

read number of arguments in c shell

I am writing script in c shell and using this script to read the command line arguments, but it is not working. Pl. someone let me know what is the problem. #!/bin/csh -f if ($#argv <> 2) then echo "you must give exactly two parameters" else set name1 = $argv ... (1 Reply)
Discussion started by: skumar11
1 Replies
Login or Register to Ask a Question