|
各位帮帮忙,我写了个简单的getops以便学习,可是系统当我输入./getopts.sh -x -y YANG -z GE *的时候,只有for里的echo显示出数据了,为什么没有打印出xopt,yopt,zopt的值啊,请问该如何做才能解决这个问题啊,下面是程序getopts.sh
while getopts ":xy:z:" opt;
do
case $opt in
X ) xopt='-x set';;
Y ) yopt="-y set and called with $OPTARG";;
Z ) zopt="-z set and called with $OPTARG";;
\? ) echo 'USAGE: getopts.sh [-x] [-y arg] [-z arg ] file ...'
exit 1
esac
done
shift $(($OPTIND - 1))
echo ${xopt: -'did not use -x'}
echo ${yopt: -'did not use -y'}
echo ${zopt: -'did not use -z'}
echo "Remaining command-line arguments are:"
for f in "$@"
do
echo -e "$f"
done |
|