shell编程-流程控制-while循环与until循环
来源:互联网 发布:淘宝企业店铺是啥意思 编辑:程序博客网 时间:2024/05/29 18:46
1. while循环
while循环是不定循环,也称作条件循环。只要条件成立,循环就会一直继续,直到条件不成立,循环才会停止。这就和for循环有一点区别。
基本格式:
while [ 条件 ] do 操作 done
示例:求1到100的和
#!/bin/bash#求1到100的和i=1s=0while [ $i -le 100 ] do s=$(( $s+$i )) i=$(( $i+1 )) doneecho "The sum is $s."
2. until循环
until循环,和while循环相反,until循环只要条件不成立,就会一直执行循环程序。一旦条件成立,循环就停止。
until [ 条件 ] do 操作 done
示例:求1到100的和
#!/bin/bash#求1到100的和i=1s=0until [ $i -gt 100 ] do s=$(( $s+$i )) i=$(( $i+1 )) doneecho "The sum is $s."
阅读全文
0 0
- shell编程-流程控制-while循环与until循环
- 流程控制:while/until循环
- linux shell编程学习--循环流程while,for,until命令
- shell循环2.while、until、select循环和循环控制
- shell for循环,while循环,until循环
- Linux shell 编程之while循环、until循环
- shell 循环 for while until ....
- shell循环,for 、while、until
- shell(for、while、until)循环
- shell-流程控制while/until
- Shell的while循环和until循环
- linux 下的Shell编程之while、until循环
- Shell Scripts - 循环while,until,for
- (12)shell for while until循环
- shell之循环 (for、while、until)
- Shell中的循环语句for、while、until
- shell 脚本之for while until循环
- shell中for、while、until循环
- RxJava
- Django实战之用户验证登录
- CSS Sticky Footer: 完美的CSS绝对底部
- Linux与安卓安全对抗
- Android对其他应用/data分区下文件的读取
- shell编程-流程控制-while循环与until循环
- mybatis入门使用3:selectKey返回最近插入的id
- 硬件模组---人人智能的人脸识别之路
- 魅族手机调试出现is waiting for debugger的问题解决
- Python Numpy 学习笔记(2)
- 关于labview中事件结构生成报表多次执行时发生数据重叠
- ToDo
- 纠结,如何选择操作系统?
- 关于spring的IoC本质