LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-24-2007, 02:50 PM   #1
tostay2003
Member
 
Registered: Jun 2006
Posts: 126

Rep: Reputation: 15
question on getopts


Is there a way that one can skip '-' using getopts.

Like for eg. If I run a script as below
Code:
./Script -a a little boy -s "2-1=1"
I want 2-1=1 as an argument for option s i.e value in OPTARG while using getopts. Is it possible??

Thanks,
Asif
 
Old 12-25-2007, 04:39 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
[QUOTE=tostay2003;3000739]Like for eg. If I run a script as below
Code:
./Script -a a little boy -s "2-1=1"
I want 2-1=1 as an argument for option s i.e value in OPTARG while using getopts. Is it possible??/QUOTE]

Yes. that is very well possible. After all that sort of things is why getopts exists.

See this section of the advanced bash scripting guide.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getopts - displaying warnings/errors when extraneous arguments are provided retrovertigo Programming 5 07-18-2007 03:44 PM
struggling with getopts mike9287 Programming 6 07-14-2006 12:42 AM
Mandatory arguments with getopts? rose_bud4201 Programming 2 03-10-2005 02:18 PM
getopts multiple parameters arnulfo Programming 2 12-23-2004 05:12 AM
Help with getopts command Rezon Programming 3 10-22-2003 04:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration