$OPTARG
 – 
Last Argument Value Processed by getopts
$OPTARG contains the value of the last option argument processed by the getopts command.
Links
Examples
- Print value passed to argument 
-v: 1 2 3 4 5 6 7 8 9 10 11 12 13usage() { echo "$0 usage: -v <value>"; exit 0; } [ $# -eq 0 ] && usage declare value # : because -v requires a value while getopts "v:" arg; do case $arg in v) value="$OPTARG" ;; *) usage ;; esac done echo "Value passed to -v: $value"
BashSupport Pro is a Zsh IDE with support for $OPTARG – try it now!