getopt / getopts

getopt / getopts#

Argument parsing (getopt external, getopts shell built-in).

$ while getopts ":hf:v" opt; do
  $ case $opt in h) usage;; f) FILE=$OPTARG;; v) VERBOSE=1;; esac
$ done

$ args=$(getopt -o hf:v --long help,file:,verbose -- "$@")