什么是最简单,最直接的使用方法getopts in bash脚本。你如何使用getopts?
,如果我有一个名为脚本:的MyScript它CAN取的参数:-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
这是一个假设的脚本,但我只想喜欢看这样做的例子。 [在bash shell脚本使用getopts的获得长期和短期的命令行选项]的
可能重复(http://stackoverflow.com/questions/402377/using-getopts-in-bash-shell -script-to-get-long-and-short-command-line-options) – 2011-10-04 13:46:43
我看过它,没有帮助我。谢谢你指出,虽然 – stackoverflow