mirror of
https://github.com/Fechin/reference.git
synced 2026-11-21 13:34:06 +03:00
Clarify bash while examples and add example per #588
This commit is contained in:
1 parent
a402c40679
commit
ee3e163b28
1 file changed
+29
-20
+29
-20
@@ -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
|
||||
|
||||
Reference in new issue
Block a user