getopts Command

The getopts command parses positional parameters for options.

Syntax
getopts options name Checks the positional parameters ($1, $2, etc.) for legal options, based on the value of options, and assigns the result to name. If an option letter is followed by a colon (\Q:'), it requires an argument. See the example at ksh OPTARG Environment Variable.
getopts options name arguments... Use the given arguments rather than the positional parameters.

where:

options is a string of option letters.

name is the name of the variable to which the result is assigned.

arguments are the arguments for the options.