[root@y_zilong ~]# sum=0;for i in {1..100};do let sum+=i;done;echo sum=$sum
sum=5050
[root@y_zilong ~]# seq -s+ 100|bc
5050
[root@y_zilong ~]# echo {1..100}|tr ' ' +|bc
5050
[root@y_zilong ~]# seq 100|paste -sd +|bc
5050
#脚本
[root@y_zilong jb]# cat f1.sh
#!/bin/bash
sum=0
for i in {1..100};do
let sum+=i;
done;
echo sum=$sum
sum=0
for ((i=1;i<=100;i+=1));do
let sum+=i;
done
echo sum=$sum
sum=0
for i in $(seq 1 100);do
let sum+=i
done;
echo sum=$sum
[root@y_zilong jb]# chmod +x f1.sh
[root@y_zilong jb]# sh f1.sh
sum=5050
sum=5050
sum=5050
[root@y_zilong jb]#