Skip to main content

Posts

Showing posts from July, 2015

Accepting long options with getopts in your shell script

Normally you can only have single-character options when processing your arguments with a standard getopts utility in Linux or Mac OS X. You can use getopt for long options, but it is not included in the standard Mac OS X installation. So this is a trick that will allow you to simulate long options with a standard getopts, that will work on all *nix platforms without additional software installations. This function will also print a usage tip if you execute the script without parameters (or with -h parameter).