shell参数处理模板
2017-08-31 17:22
525 查看
存一份模板,以后简单参数处理就用它了
#!/bin/bash while getopts h:ms option #选项后面的冒号表示该选项需要参数 do case "$option" in h) echo "option:h, value $OPTARG" #参数存在$optarg中 echo "next arg index:$OPTIND";; m) echo "option:m" echo "next arg index:$OPTIND";; s) echo "option:s" echo "next arg index:$OPTIND";; \?) #当有不认识的选项的时候arg为? echo "Usage: args [-h n] [-m] [-s]" echo "-h means hours" echo "-m means minutes" echo "-s means seconds" exit 1;; esac done
相关文章推荐
- shell脚本处理长参数的模板
- shell脚本处理长参数的模板
- 参数处理-Shell传入参数的处理
- Shell传入参数的处理
- Shell传入参数的处理
- [shell]shell脚本-求和&参数处理等
- shell多参数处理技巧
- Bash Shell中命令行选项/参数处理
- 脚本乐园 Shell中命令行选项和参数的处理
- 使用润乾参数模板后如何对参数进行二次处理
- 脚本乐园 Shell中命令行选项和参数的处理
- 使用getopts处理Shell脚本参数
- Bash Shell中命令行选项/参数处理
- 使用getopts处理shell中的输入参数
- shell--传入参数的处理
- shell传入参数的处理
- Shell处理用户输入参数----getopts
- shell中通过${}处理脚本参数
- Shell 参数的读取和处理
- 使用getopt处理shell脚本的参数 推荐