shell脚本中使用getopts接收参数的使用方法
QQ群:397745473
1 | 参考: |
命令行选项可以分为3种类型:
-不带参数的选项:
-带有参数的选项:
-选项+其他命令行参数:
getopts命令的语法为:
1 | getopts optstring name |
案例:
1 | #!/bin/sh |
结果:
1 | # ./disp.sh -d |
上面这些基本够用,更多可以参考英文文档:
1 | http://puremonkey2010.blogspot.com/2016/05/linux-bash-getopts.html |
QQ群:397745473