2016-01-05 20:47:12 +02:00
|
|
|
# while
|
|
|
|
|
2024-12-26 20:14:04 +02:00
|
|
|
> Simple shell loop that repeats while the return value remains zero.
|
2023-08-08 13:21:15 +03:00
|
|
|
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_09>.
|
2016-01-05 20:47:12 +02:00
|
|
|
|
2022-12-04 08:53:34 +01:00
|
|
|
- Read `stdin` and perform an action on every line:
|
2016-01-05 20:47:12 +02:00
|
|
|
|
|
|
|
`while read line; do echo "$line"; done`
|
|
|
|
|
2016-01-13 12:04:46 +01:00
|
|
|
- Execute a command forever once every second:
|
2016-01-05 20:47:12 +02:00
|
|
|
|
|
|
|
`while :; do {{command}}; sleep 1; done`
|
2024-12-08 00:39:46 +02:00
|
|
|
|
2024-12-26 20:14:04 +02:00
|
|
|
- Execute a command until it fails:
|
2024-12-08 00:39:46 +02:00
|
|
|
|
|
|
|
`while {{command}}; do :; done`
|