tldr/pages/common/while.md

12 lines
213 B
Markdown
Raw Normal View History

2016-01-05 21:47:12 +03:00
# while
2016-01-13 14:04:46 +03:00
> Simple shell loop.
2016-01-05 21:47:12 +03:00
2016-01-13 14:04:46 +03:00
- Read stdin and perform an action on every line:
2016-01-05 21:47:12 +03:00
`while read line; do echo "$line"; done`
2016-01-13 14:04:46 +03:00
- Execute a command forever once every second:
2016-01-05 21:47:12 +03:00
`while :; do {{command}}; sleep 1; done`