Parse shell options from arguments. This command does not support longform options and thus using
getoptis recommended instead. More information: https://www.gnu.org/software/bash/manual/bash.html#index-getopts.
getopts {{x}} {{opt}}; echo $opt
getopts {{x}}: {{opt}}; echo $OPTARG
while getopts {{xyz}} {{opt}}; do case $opt in x) echo x is set;; y) echo y is set;; z) echo z is set;; esac; done
getopts to silent mode and handle option errors:while getopts :{{x:}} {{opt}}; do case $opt in x) ;; :) echo "Argument required";; ?) echo "Invalid argument" esac;; done
getopts:OPTIND=1