什麼是最簡單,最直接的使用方法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