getopt OPTSTRING VAR
OPTSTRING contains the option letters. Add a colon to an options if this option has a required argument or two colons for an optional argument. The current option is saved in VAR, arguments are saved in $OPTARG. Any non-option arguments can be accessed starting from $1.