在shell中使用while循环的例子
来源:互联网 发布:非洲有没有帅哥知乎 编辑:程序博客网 时间:2024/06/10 19:24
- #!/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
执行这个脚本后,输出的结果为:
9
10
11
12
13
14
15
注意: 第9行的功能和第10行的功能是一样的。
下面的例子是使用一个循环,必须输入一个数字才能退出.
- #!/bin/sh
- #filename:b
- while :
- do
- echo -n "input a number:"
- read Val
- expr $Val + 1 > /dev/null 2>
- res=$?
- if [ "$Val" = "" ] || [ "$res" != "0" ]; then
- echo "what you input is not a number!"
- else
- echo "what you input is : $Val"
- break;
- fi
- done
- 在shell中使用while循环的例子
- shell下在while循环中使用ssh命令的问题
- shell中使用while循环ssh的注意事…
- shell 循环语句while的使用
- shell的while循环
- shell循环sleep while例子 条件判断
- shell中while循环案例
- shell 中for、while循环
- continue在while循环的使用,禁忌
- Shell脚本基础16-while循环中使用sleep命令
- shell里的while循环
- shell 关于 while 循环中赋值的问题
- shell 脚本中while 循环只执行一次的问题
- shell 脚本中while 循环只执行一次的问题
- Shell的while循环和until循环
- while循环的使用
- 有关Java中try catch无法在while循环中使用的情况
- 有关Java中try catch无法在while循环中使用的情况
- Oracle/PLSQL: Foreign Keys
- classmethod,staticmethod,还有类里面一般的的method有什么区别
- 浅谈.NET中的数据绑定表达式(二)
- NCR5887 ATM机出钞时卡钞解决方法-NCR5887常见故障系列二
- Succes in speech
- 在shell中使用while循环的例子
- WinCE内核定制
- C# 3.0新特性系列:隐含类型var
- NK.bin与NK.nb0的区别以及binfs和它们的关系
- 锁定及解锁oracle数据库用户!
- 欢迎大象读者加入QQ群75809242讨论,感谢网友“网痞”建立“大象UML民间读者群”!
- 在linux终端下运行X Window程序
- SQL Server性能调优杂记4(小心SQLCmd的动态参数方法让你堕入性能问题)
- ejb3.0在linux下分布式系统部署