![]() |
|
|
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 |
| getopts: bad option(s) | JoeJoseph | Shell Programming and Scripting | 1 | 08-19-2008 04:14 PM |
| getopts with non-option arguments? | kdelok | Shell Programming and Scripting | 2 | 07-26-2008 11:44 PM |
| option followed by : taking next option if argument missing with getopts | gurukottur | Shell Programming and Scripting | 2 | 03-17-2008 12:46 PM |
| to copy and repeat | falcondown01 | Shell Programming and Scripting | 4 | 09-07-2007 09:15 PM |
| Repeat Commands | dereckbc | UNIX for Dummies Questions & Answers | 6 | 01-04-2005 11:15 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
getopts with repeat of same option
Hello, Does getopts have some way of handling the use of an option that requires a parameter more than once on the command line. e.g. mycmd -a john -a jane I came up with a solution using arrays (shown below), but wonder if getopts has some other way of handling it. Other solutions welcome. Code:
x=1
while getopts a:b OPTION
do
case $OPTION in
a) AA[$x]=$OPTARG ;;
b) true
esac
x=$((x+1))
done
Thank you Last edited by CarlosNC; 10-23-2008 at 05:13 PM.. Reason: Add code tag |
| Bookmarks |
| Tags |
| bash, getopts |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|