I wish to pass long and short CLI options. I have tried below for short options:
#!/bin/bash while getopts d:t:r: option do case "${option}" in d) c_date=${OPTARG};; t) c_type=${OPTARG};; r) c_date_range=${OPTARG};; esac done shift $((OPTIND -1)) echo "Date:"$c_date echo "Type:"$c_type echo "Range:"$c_date_range
How can I accept long options like --date, --type, --range?
- The range option accepts 2 dates i.e.
-r 2019-01-01 2019-02-01
or--range 2019-01-01 2019-02-01
. How can I accept these dates and save in separate variables?