2025-03-14 21:59:59 -06:00
|
|
|
# while
|
|
|
|
|
|
|
|
|
|
> Simple shell loop that repeats while the return value remains zero.
|
2025-12-16 10:20:31 -07:00
|
|
|
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-while>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Read `stdin` and perform an action on every line:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`while read line; do {{echo "$line"}}; done`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Execute a command forever once every second:
|
|
|
|
|
|
|
|
|
|
`while :; do {{command}}; sleep 1; done`
|
|
|
|
|
|
|
|
|
|
- Execute a command until it fails:
|
|
|
|
|
|
|
|
|
|
`while {{command}}; do :; done`
|