1 [root@localhost array]# cat for.sh 2 #!/bin/bash 3 for i 4 do 5 #echo abc 6 let sum+=$i 7 done 8 echo $sum 9 [root@localhost array]# sh for.sh 1 2 3 4 5 10 15 11 [root@localhost array]#
等价与
1 [root@localhost array]# cat for.sh 2 #!/bin/bash 3 for i in $* 4 do 5 #echo abc 6 let sum+=$i 7 done 8 echo $sum 9 [root@localhost array]# sh for.sh 1 2 3 4 5 10 15 11 [root@localhost array]#