First page Back Continue Last page Graphics
getops
getopts optionstring variable [argumentlist]
It will use the positional parameters unless the optional argumentlist is supplied.
getopts puts the matching option character into your variable and puts the number of the next char into OPTIND.
If the option is not matched, variable is set to "?" and an error message is written to stderr (unless ":" is the first character of optionstring to suppress that behaviour).
Dash arguments that have arguments themselves (like cut -f 5) can be followed by a colon in optionlist, and the next item in the parameter list will be assigned to OPTARG for use in the script.
Processing stops when the first non-dash argument is found.