getopt is used to break up options in command lines for easy parsing by shell procedures, and to check for legal options. [
Optstring] is a string of recognized option letters (see
getopt(3)); if a letter is followed by a colon, the option is expected to have an argument which may or may not be separated from it by white space. The special option “--” is used to delimit the end of the options.
getopt will place “--” in the arguments at the end of the options, or recognize it if used explicitly. The shell arguments (
$1,
$2,
...) are reset so that each option is preceded by a “-” and in its own shell argument; each option argument is also in its own shell argument.
getopt should not be used in new scripts; use the shell builtin
getopts instead.