tldr/pages/common/while.md

12 lines
213 B
Markdown
Raw Normal View History

2016-01-05 18:47:12 +00:00
# while
2016-01-13 11:04:46 +00:00
> Simple shell loop.
2016-01-05 18:47:12 +00:00
2016-01-13 11:04:46 +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`