你如何使用 getopts?
在 bash 脚本中使用 getopts 的最简单、最直接的方法是什么?
如果我有一个名为:myscript 的脚本,并且它可以采用参数:-p -r -s -x
if argument x then exit
if argument p then echo "port 10"
if argument s then add 2+2
if argument r then echo env
这是一个假设的脚本但我只想看一个如何完成此操作的示例。
what is the easiest, most straight forward, way to use getopts in bash script.
if i have a script called: myscript and it CAN take the the arguments: -p -r -s -x
if argument x then exit
if argument p then echo "port 10"
if argument s then add 2+2
if argument r then echo env
This is a hypothetical script but I would just like to see an example of how this would be done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)