The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-23-2008
CarlosNC CarlosNC is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 6
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0