tldr/pages/common/while.md

13 lines
261 B
Markdown
Raw Permalink Normal View History

2016-01-05 18:47:12 +00:00
# while
2016-01-13 11:04:46 +00:00
> Simple shell loop.
> More information: <https://manned.org/while>.
2016-01-05 18:47:12 +00:00
- Read stdin and perform an action on every line:
2016-01-05 18:47:12 +00:00
`while read line; do echo "$line"; done`
2016-01-13 11:04:46 +00:00
- Execute a command forever once every second:
2016-01-05 18:47:12 +00:00
`while :; do {{command}}; sleep 1; done`