knowledge/technology/applications/cli/Loop.md
2023-12-04 11:02:23 +01:00

27 lines
No EOL
1.1 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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!**