shell脚本实现求和
1: 1+2+...+9+10
#!/bin/bash
let init=0
for i in {1..10..1}
do
# echo $sum
let sum=$sum+$i
done
echo $sum
运行结果
2: 1+3+...+9
#!/bin/bash
let init=0
for i in {1..10..2}
do
# echo $sum
let sum=$sum+$i
done
echo $sum
运行结果
标签:脚本,10,shell,..,求和,sum,echo,let From: https://www.cnblogs.com/rainbow7colours/p/16997277.html