Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1441904
  • 博文数量: 244
  • 博客积分: 3353
  • 博客等级: 中校
  • 技术积分: 3270
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-09 17:56
文章分类

全部博文(244)

文章存档

2023年(7)

2022年(7)

2021年(4)

2020年(1)

2019年(2)

2017年(2)

2016年(3)

2015年(11)

2014年(20)

2013年(10)

2012年(176)

分类: Python/Ruby

2012-06-21 22:09:57


#!/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
~
  1. #!/bin/sh
  2. #filename:2.sh
  3. b=9
  4. e=15
  5. tmpb=$b
  6. while [ $tmpb -le $e ]
  7. do
  8. echo $tmpb
  9. #tmpb=`expr $tmpb + 1` //ok
  10. tmpb=$(expr $tmpb + 1)
  11. done

4.使用数组
  1. #!/bin/sh
  2. a1="11 12 13"
  3. a2="21 22 23"
  4. a3="31 32 33"
  5. for index in a1 a2 a3
  6. do
  7.   eval d1=\$$index
  8.   for d2 in $d1
  9.   do
  10.     echo $d2
  11.   done
  12. done
  13. #----- eof -----#

5. 调用文件中的变量

cat var.tmp | while read user
do

echo $user

done

阅读(930) | 评论(0) | 转发(0) |
0

上一篇:linux/unix常见知识摘要

下一篇:ssh自动登录

给主人留下些什么吧!~~