getopts — Parse Utility Options

Synopsis

/usr/bin/getopts optstring name [arg...] 
sh
getopts optstring name [argument...] 
ksh
getopts optstring name [arg...] 

Description

/usr/bin/getopts

You can use the getopts command to process command-line arguments and check for legal options. You use the getops command in shell script loops to ensure standard syntax for command-line options.

Each time it is invoked, the getopts command puts the value of the next option in the shell variable specified by the name operand and the index of the next argument to be processed in the shell variable OPTIND. Whenever the shell is invoked, OPTIND is initialized to 1.

When the option requires an option-argument, the getopts command puts it in the shell ...

Get Solaris™ 7 Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.