例:./test.sh one two three
其中one two three是傳入 test.sh 的參數
$0: script 本身的檔案名稱
$1: 代表第一個參數 (one)
$2: (two)
...
$#: 參數的總數,也就是 3
$*: 代表 "one two three"
$@: 則是 "one" "two" "three"
shift 用來移動參數的位置
每執行一次 則所有的參數往左移一位
此時 $1 為 two,$2 為 three
set 用來重新設定位置參數 比如:set a b c d
則設定 $1 為 a, $2 為 b, $3 為 c, $4 為 d
訂閱:
張貼留言 (Atom)
0 comments:
張貼留言