bash – 在getopts之后解析参数
发布时间:2020-12-15 19:28:52 所属栏目:安全 来源:网络整理
导读:我想打这个bash脚本 $ ./scriptName -o -p -t something path/to/file 这是我得到的 #!/bin/basho=falsep=falsewhile getopts ":opt:" optionsdo case $options in o ) opt1=true ;; p ) opt2=true ;; t ) opt3=$OPTARG ;; esacdone 但是如何获取路径/到/文
我想打这个bash脚本
$ ./scriptName -o -p -t something path/to/file 这是我得到的 #!/bin/bash o=false p=false while getopts ":opt:" options do case $options in o ) opt1=true ;; p ) opt2=true ;; t ) opt3=$OPTARG ;; esac done 但是如何获取路径/到/文件?
你可以这样做:
shift $(($OPTIND - 1)) first_arg=$1 second_arg=$2 循环运行后。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Shell重定向&>file、2>&1、1>&
- scala – 为什么这个结构类型绑定不能按预期工作
- angular2使用嵌套导入模块的组件
- 在Angular 2 RC5 / Router 3 RC1中路由嵌套模块
- 在Scala中运行时有效类型转换covariant和contrav
- webservice 笔记(小结) axis2 集成spring 传递对
- 使用Eclipse Pydev在Docker容器中远程调试Odoo /
- 从Angular 2应用程序中的任何位置关闭辅助路径
- scala – 为“免费”获取案例类的部分构造函数
- 解决windows10 连接Memcached时不能使用telnet命
热点阅读