- 论坛徽章:
- 0
|
各位高手帮帮忙啊
我写的一个关于getopts的简单脚本在系统中运行后显示无法找到$OPTIND这个内置变量,请问下要怎么解决啊,下面是我的脚本代码
while getopts " y:z:" opt;
do
case $opt in
X )opt='-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 |
|