I am trying to parse incoming options in my bash script, and save the values in variables.
This is my code:
#!/bin/bash
while getopts "H:w:c" flag
do
# echo $flag $OPTIND $OPTARG
case $flag in
H) host = "$OPTARG"
;;
w) warning = "$OPTARG"
;;
c) critical = "$OPTARG"
;;
esac
done
However, the statements inside ‘case’ must be command-line commands, so I can’t make the wanted assignment. What is the right way to do this?
Remove the spaces around the
=operators: