#example test.sh -param1 value1 -param2 value2 while [[ $# -gt 0 ]]; do case "$1" in -param1) shift; echo "the value of param1 is",$1 shift ;; -param2) shift; echo "the value of param2 is",$1 shift ;; *) echo "param error" echo "output help information" exit 1 ;; esac done
或者參考這篇博文中的短參數html