bash shell脚本while循环

例子:

powershell 复制代码
~ script % vim while.sh
~ script % ./while.sh

while.sh:

powershell 复制代码
#!/usr/bin/env bash

COUNT=0

while [ $COUNT -lt 10 ]
do
	echo "Count # $COUNT"
	((COUNT++))
done
exit 0
powershell 复制代码
script % ./while.sh  
Count # 0
Count # 1
Count # 2
Count # 3
Count # 4
Count # 5
Count # 6
Count # 7
Count # 8
Count # 9

语法:

powershell 复制代码
while [ 循环条件 ]
do
	循环体
done

powershell 复制代码
while test 循环条件 
do
	循环体
done

while循环还是比较简单的。

相关推荐
hsjkdhs18 分钟前
C++之类的继承与派生
开发语言·c++
lly20240641 分钟前
HTML 元素:构建网页的基础
开发语言
低调小一42 分钟前
LRU缓存科普与实现(Kotlin 与 Swift)
开发语言·缓存·kotlin
爱好学习的青年人42 分钟前
一文详解Go语言字符串
开发语言·后端·golang
浅川.251 小时前
xtuoj string
开发语言·c++·算法
望获linux1 小时前
【实时Linux实战系列】实时系统的可观测性:Prometheus 与 Grafana 集成
大数据·linux·服务器·开发语言·网络·操作系统
加油吧zkf1 小时前
Python入门:从零开始的完整学习指南
开发语言·前端·python
xqlily2 小时前
Kotlin:现代编程语言的革新者
android·开发语言·kotlin
csbysj20203 小时前
XSLT Apply:深入解析XSLT在XML转换中的应用
开发语言
不会kao代码的小王3 小时前
突破机房围墙:openEuler设备的公网管理实战指南
开发语言·数据库·笔记