While Loop :
Description: The while loop is an indeterminate loop, also known as a conditional loop. As long as the condition is judged, the loop will continue to execute until the condition is judged, and the loop will stop, which is not the same as for the fixed loop,
1 while [conditional judgment] 2 Do 3 procedure 4 Done
Example:
1[Email protected] bash]#VIWhile1.SH2#!/bin/Bash3 #从1到1004I=15s=06 while[$i-le -] ; Do7s=$ (($s +$i))8i=$ (($i +1 ))9 DoneTen Echo "The sum is: $s" One[Email protected] bash]#chmodU+x While1.SH A[Email protected] bash]#./while1.SH -Thesumis:5050
2.until Loop:
Description: In contrast to the while loop, the until loop is executed as long as the condition is not established, until the condition is stopped
1[Email protected] bash]#VINutil1.SH2#!/bin/Bash3I=14s=05 until[$i-GT - ]6 Do7s=$ (($s +$i))8i=$ (($i +1 ))9 DoneTen Echo "The sum is: $s" One[Email protected] bash]#chmodU+x Nutil1.SH A[Email protected] bash]#./nutil1.SH -Thesumis:5050
Ok
Shell Learning Path: Process Control (while)