全部博文(43)
分类: LINUX
2010-09-17 18:23:53
/path/to/scriptname opt1 opt2 opt3 opt4
$0 $1 $2 $3 $4
- $# :代表後接的參數『個數』,以上表為例這裡顯示為『 4 』;
- $@ :代表『 "$1" "$2" "$3" "$4" 』之意,每個變數是獨立的(用雙引號括起 來);
- $* :代表『 "$1c$2c$3c$4" 』,其中 c 為分隔字元,預設為空白鍵, 所以 本例中代表『 "$1 $2 $3 $4" 』之意。
eg: sh sho7.sh one two three four five $0 ==> "sho7.sh" $1 ==> "one" $2 ==> "two" $3 ==> "three" $4 ==> "four" $# ==> 5 $@ ==> "one two three four five"