例1:
#!/bin/bash
sum=0;
for i in {1..100..2}
do
let "sum+=i"
done
echo "the sum is $sum"
例2:
#!/bin/bash
cd /root
ls *.sh > ls.log
y=1
for i in $(cat ls.log)
do
echo $y
y=$(( $y + 1 ))
done
原文:http://www.cnblogs.com/bluewelkin/p/3959645.html