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]# 

 

相关文章:

  • 2021-10-24
  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-13
  • 2021-06-27
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案