示例:shell
腳本test.shcode
#!/bin/sh ten=$10 echo $ten
執行腳本:class
sh test.sh 0 1 2 3 4 5 6 7 8 9
輸出結果不是test
9
而是腳本
00
爲何呢?co
由於"$10"被解析成了「$1」和「0」。參數
如何解決?
修改腳本
#!/bin/sh ten=${10} echo $ten
讓sh將「10」做爲參數展開。