I am trying to parse a -temp option with Bash getopts. I'm calling my script like this:
./myscript -temp /foo/bar/someFile
Here is the code I'm using to parse the options.
while getopts "temp:shots:o:" option; do
case $option in
temp) TMPDIR="$OPTARG" ;;
shots) NUMSHOTS="$OPTARG" ;;
o) OUTFILE="$OPTARG" ;;
*) usage ;;
esac
done
shift $(($OPTIND - 1))
[ $# -lt 1 ] && usage