Use the getopts shell utility
while getopts d:s o
do case "$o" in
d) value_of_d="$OPTARG";;
s) saw_an_s="TRUE";;
esac
done
shift $OPTIND-1
# the remaining arguments are in $*
In getopts optstring name
the string optstring
contains a letter for each option that the script understands, follow a letter with :
if the option receives an argument.