1. for循环
#!/bin/bash
a=0
for ((i=0 ; i <= 100; i++ ))
do
a=$((a+i))
done
echo $a
2. awk语句
[root@localhost ~]# awk 'BEGIN { for(i=1; i<=100; i++) sum+=i; print sum}'
1. for循环
#!/bin/bash
a=0
for ((i=0 ; i <= 100; i++ ))
do
a=$((a+i))
done
echo $a
2. awk语句
[root@localhost ~]# awk 'BEGIN { for(i=1; i<=100; i++) sum+=i; print sum}'