shell-使用getopts指定变量取值
来源:互联网 发布:天庭淘宝城宋小刀txt 编辑:程序博客网 时间:2024/05/16 23:47
getoption读取option_string,获知脚本中使用了有效的选项,getopts查看所有以连字符开头的参数,将其视为选项,如果输入选项,讲把这个与option_string对比,如果匹配发现,变量设置为OPTION,如果未发现匹配字符,变量能够设置为?
!/bin/bashALL=falseHELP=falseFILE=falseVERSION=falseCOPIES=0while getopts :ahfgvc: OPTION#:ahfgvc:和ahfgvc:的区别,前者是屏蔽getopts自带的错误提示信息,后者是执行自带的#c:的意思是c后面必须有个参数才行否则无效 c 100do case $OPTION in a)ALL=true echo "ALL is $ALL" ;; h)HELP=true echo "HELP is $HELP" ;; f)FILE=true echo "FILE is $FILE" ;; v)VERSION=true echo "VERBOSE is $VERSION" ;; c)COPIES=$OPTARG echo "COPIES is $COPIES" ;; \?)echo "`basename $0` -[a h f v] -[c value] file" >&2 esacdone
2 0
- shell-使用getopts指定变量取值
- Shell编程之getopts指定变量取值
- [shell] getopts使用
- shell getopts使用
- shell getopts
- shell-----getopts
- shell--getopts
- 使用getopts处理Shell脚本参数
- 使用getopts处理shell中的输入参数
- 使用getopts处理Shell脚本参数 (转)
- 使用getopts处理shell中的输入参数
- 使用getopts处理shell中的输入参数
- Shell中使用getopt、getopts命令
- 使用getopts
- getopts使用
- bash shell脚本处理传参,getopts的使用
- shell中getopt/getopts的使用 getarg和getind意义
- 在shell脚本中使用getopts处理参数
- win8.1开机出错pniopcac.exe报错win8.1系统安装STEP7 Micro/Win V4.0 SP9
- Universal-Image-Loader,android-Volley,Picasso、Fresco和Glide五大Android开源组件加载网络图片比较
- swift学习之路(十)字典
- Android开发--常用的传感器总结
- 安卓volley框架基本使用
- shell-使用getopts指定变量取值
- c++重载总结
- Cuda编程 之 块(block)计算
- AOP TableView
- IOS开发 applicationDidBecomeActive 应用程序挂起、复原与终止
- leetcode 342. Power of Four
- Android Studio遇到的那些坑及爬坑方法
- 【课设】模拟实现动态内存分配—首次适应算法
- JVM调优系列(二)——JVM内存分配解析