Odkazy:
Pro analýzu parametrů můžeme s výhodou použít příkaz getopts. Uvedu vzorové použití:
while getopts "an:p:hv" optname; do
case "$optname" in
"v")
ssversion="$OPTARG"
;;
"a")
echo "Option $optname is specified"
;;
"n")
echo "Option $optname has value $OPTARG"
;;
"p")
echo "Option $optname has value $OPTARG"
;;
"h")
echo "Option $optname is specified"
;;
*)
errormsg="Unknown parameter or option error with option - $OPTARG"
echo "Unknown error while processing options"
;;
esac
echo "OPTIND is now $OPTIND"
donewhile getopts "h" OPTIONS; do
case ${OPTIONS} in
h|-help) echo "${usage}";;
esac
donewhile getopts ":u:a:s:v" options; do
case $options in
u) uname=$OPTARG;;
a) attrs=$OPTARG;;
s) searchattr=$OPTARG;;
v) att=ALL;;
h) echo $usage;;
\?) echo $usage
exit 1;;
*) echo $usage
exit 1;;
esac
done