getopts opstring name [args]
getopts用户获得命令行位置参数
opstring 表示参数, :表示:前边的参数需要带值
name 表示取得的参数,
获得的参数变量存储到 OPTARG 里边
错误 1.opstring以colon(:)开始, silent error reporting
2.OPTERR=0 silent error reporting
显示的错误种类: 非法选项, 缺少参数
常见用法
while getopts opstring OPTION
do
case $OPTION
in
a);;
b);;
\?);;
esac
done