Reading $OPTARG for optional flags?

: means “takes an argument”, not “mandatory argument”. That is, an option character not followed by : means a flag-style option (no argument), whereas an option character followed by : means an option with an argument.

Thus, you probably want

getopts "a:b:c:d:e:f:" opt

If you want “mandatory” options (a bit of an oxymoron), you can check after argument parsing that your mandatory option values were all set.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)