This is the code I'm working with:
TYPE=""
FILE=""
while getopts "t:f:" opt; do
case $opt in
t) TYPE="$OPTARG"
;;
f) FILE="$OPTARG"
;;
esac
done
if [ -z "$TYPE" ]; then
echo "No -t. Bye."
exit 1 # error
else
if [ -n "$FILE" ]; then
echo "$TYPE and $FILE"
else
echo JUST $TYPE
fi
fi
Is it possible to specify valid options for $TYPE? For example valid type options are:
IMAGE, ZIP, DOC
If one of these types are specified as valid arguments then the script runs the existing line:
"echo "$TYPE and $FILE""
Otherwise it echos an error and quits. Is this possible to do?