a question about getopts command...
suppose I have the following inside my script..
while getopts :x:y: argument
do
case $argument in
x) var1=$OPTARG;;
y) var2=$OPTARG;;
echo "No argument given";;
esac
done
in my script, option x is required, no problem. But
option y is not. How do I test to see if option y
was indeed entered on the command line and if not, set some other value to var2.
Thanks.
suppose I have the following inside my script..
while getopts :x:y: argument
do
case $argument in
x) var1=$OPTARG;;
y) var2=$OPTARG;;
echo "No argument given";;
esac
done
in my script, option x is required, no problem. But
option y is not. How do I test to see if option y
was indeed entered on the command line and if not, set some other value to var2.
Thanks.