getopts的用法
来源:互联网 发布:qq机器人源码 编辑:程序博客网 时间:2024/06/06 12:36
getopts 命令 :用来从参数列表检索选项以及选项参数。getopts option_string variable ,option_string 可以理解为参数列表。执行命令时会从命令行中的选项与optin_string匹配,如果匹配成功,会把参数赋值到variable。如果选项后面跟:(冒号),则预期此选项将带有参数。
getopts ab:c:d 选项b和c将要带参数。
getopts ab:c:d 与 getopts :ab:c:d 的区别:当option_string 不以:(冒号)开头时,选项缺少参数会在标准输出中提示,否则,不会提示。
$OPTARG 内部变量,选项的有参数会被赋值到 $OPTARG
#!/bin/bash
if [ $# -eq 0 ];then
echo "argument is need -ijm"
exit 0
fi
while getopts i:j:m opt
do
echo "OPTIND is $OPTIND"
case $opt in
"i")
echo "option is i,value is $OPTARG";;
"j")
echo "option is j,value is $OPTARG";;
"m")
echo "option is m";;
*)
echo "ERROR OPTARG is $OPTAGR";;
esac
done
- *getopts的用法*
- shell 的getopts用法
- getopts的用法
- getopts的用法解读
- getopts的用法
- shell - getopts的实效用法
- getopts用法
- getopts 命令用法总结
- shell getopts 用法
- SHELL:getopts用法介绍
- getopts 用法详解
- shell getopts用法详解
- shell getopts 用法
- shell getopts 用法
- shell getopts 用法
- shell getopts 用法
- shell getopts 用法
- getopts 和 getopt 用法简记
- HTML中的URL编码规则
- Spring与Struts1整合的三种方法总结
- Parse-轻松构建移动APP的后台服务
- HTML5实战与剖析之CSS选择器——getElementsByClassName()方法
- 【玩转cocos2d-x之一】V2.2.0版本开发环境配置
- getopts的用法
- GPIO驱动框架
- 单引号,双引号,javascript,HTML,转义字符
- Windows 7 关闭最后一个资源管理器就自动重启
- android的color值
- 网页数据抽取技术调研
- Asterisk权威指南/第三章 安装Asterisk
- ORACLE EXPDP命令使用详细
- Js特效