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循环还是比较简单的。

相关推荐
hsjiasb4 小时前
FreeRTOS学习(二十七)——任务栈与栈溢出检测
开发语言·stm32·学习·学习笔记·freertos
丰锋ff5 小时前
3.1 Qt事件之事件处理器
开发语言·qt
多弗朗皮卡丘5 小时前
C语言梦开始的地方7:函数
c语言·开发语言
月华路6 小时前
G1 垃圾回收:脏卡队列、记忆集与并发精化线程机制
java·开发语言
gugucoding6 小时前
47. 【Java】Java内存模型(JMM)与可见性
java·开发语言
m0_380743876 小时前
从零调用 Claude 教程
开发语言·python·node.js
起床学FPGA7 小时前
AI回答问题之后,会自动跳到最下面的问题
开发语言·javascript·ecmascript
x_x-F8 小时前
网络数据从网卡到用户态:一场基于内存所有权转移的接力赛
开发语言·网络·php
名字还没想好☜8 小时前
Java 线上内存泄漏排查实战:jmap 导堆、MAT 找 GC Roots 与四类常见泄漏
java·开发语言·jvm·内存泄漏
码匠许师傅8 小时前
【C++ 面试真题】聊聊 C++ 的多继承与虚继承
开发语言·c++·面试