![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | 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. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
getopts case statement failure
Hi, I have a getopts that works fine if I provide an option but I want it to exit if nothing is given, but for some reason it drops out and continues with the script. Any ideas? Code:
while getopts d:m:y: o
do
case $o in
d) day=$OPTARG
;;
m) month=$OPTARG
;;
y) year=$OPTARG
;;
:) echo "Option $OPTARG needs an argument"; usage
;;
*) usage
;;
esac
done
script_name.sh -d 25 -m Nov -y 09 Cheers and beers, Neil |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with case statement | rkruck | Shell Programming and Scripting | 1 | 06-03-2009 04:06 PM |
| ksh case statement | dgilc | Shell Programming and Scripting | 2 | 12-16-2008 04:34 PM |
| case statement | c00kie88 | Shell Programming and Scripting | 2 | 10-12-2008 06:08 PM |
| If or Case Statement | Ernst | UNIX for Dummies Questions & Answers | 1 | 09-24-2008 06:00 PM |
| Case Statement | Zeta_Acosta | Shell Programming and Scripting | 19 | 04-06-2004 05:16 PM |