Clarify bash while examples and add example per #588

This commit is contained in:
Paul Gallagher committed 2025-06-08 23:11:20 +08:00
1 parent a402c40679
commit ee3e163b28
1 file changed
+29 -20
+29 -20
View File
@@ -515,26 +515,6 @@ for i in {5..50..5}; do
done
```
### Auto increment
```bash
i=1
while [[ $i -lt 4 ]]; do
echo "Number: $i"
((i++))
done
```
### Auto decrement
```bash
i=3
while [[ $i -gt 0 ]]; do
echo "Number: $i"
((i--))
done
```
### Continue
```bash {data=3,5}
@@ -569,6 +549,35 @@ until [ $count -gt 10 ]; do
done
```
### While with increment
```bash
i=1
while [[ $i -lt 4 ]]; do
echo "Number: $i"
((i++))
done
```
### While with decrement
```bash
i=3
while [[ $i -gt 0 ]]; do
echo "Number: $i"
((i--))
done
```
#### Combined with test
```bash
i=3
while ((i--)); do
echo "Number: $i"
done
```
### Forever
```bash