knowledge/technology/applications/cli/Loop.md

27 lines
1.1 KiB
Markdown
Raw Normal View History

2023-12-04 10:02:23 +00:00
---
obj: application
os: linux
repo: https://github.com/Miserlou/Loop
---
# Loop
[Repo](https://github.com/Miserlou/Loop)
Loops in bash are surprisingly complicated and fickle! I wanted a simple and intuitive way to write controllable loops that:
- Run on controllable **timers**!
- `$ loop --every 10s -- ls`
- Have **custom counters**!
- `$ loop --count-by 5 -- 'touch $COUNT.txt'`
- Loop **until output matches** a condition!
- `$ loop --until-contains 200 -- ./get_response_code.sh --site mysite.biz`
- Loop **until a certain time**!
- `$ loop --for-duration 8h -- ./poke_server`
- Loop **until a program succeeds** (or fails!)
- `$ loop --until-success -- ./poke_server`
- Iterate over the **standard input**!
- `$ cat files_to_create.txt | loop -- 'touch $ITEM'`
- Get a **summary** of the runs!
- `$ loop --for-duration 10min --summary -- ls`
- Run until output **changes or stays the same** between invocations!
- `$ loop --until-changes -- date +%s`
- `$ loop --until-same -- date +%s`
- ..and **much more!**