#!/bin/bash
clear
for((i=1;i<100;i++))
for
do
if((i%3==0))
then
echo $i
continue
fi
done
2.使用`seq 100`
#!/bin/bash
clear
for i in `seq 100`
do
if((i%3==0))
then
echo $i
continue
fi
done
3.使用while
#!/bin/bash
limit=5
i=0
while [ $i -le $limit ]
do
echo -e "################## This is loop $i time No audit ######################"
i=$(($i+1))
done
~
- #!/bin/sh
- #filename:2.sh
- b=9
- e=15
- tmpb=$b
- while [ $tmpb -le $e ]
- do
- echo $tmpb
- #tmpb=`expr $tmpb + 1` //ok
- tmpb=$(expr $tmpb + 1)
- done
4.使用数组
- #!/bin/sh
-
- a1="11 12 13"
- a2="21 22 23"
- a3="31 32 33"
-
- for index in a1 a2 a3
- do
- eval d1=\$$index
- for d2 in $d1
- do
- echo $d2
- done
- done
-
- #----- eof -----#
5. 调用文件中的变量
cat var.tmp | while read user
do
echo $user
done
阅读(958) | 评论(0) | 转发(0) |