Chapter 5: Bash Scripting for Automation
Chala mitrano, aaj aapan Bash scripting shikuya. Dar sakali don-das commands type karnyachi paddhat sodun, ek script — health check, pull, restart. Shebang, variables, quotes, exit codes, if / loops, thodi idempotent habit, cron, aani secrets hardcode nahi. Ghabru naka: pahili script short theva; perfect poetry nahi — clear aani safe.
What you will learn in this chapter
- Shebang, variables, quotes, exit codes
- if and loops for health checks
- Check-before-install script habits
- Cron basics and PATH pitfalls
- Keep secrets out of scripts
Concepts in this chapter
- 5.1Why script — the morning ten commands
- 5.2Shebang, permissions, first script
- 5.3Variables, quotes and exit codes
- 5.4if and loops for health checks
- 5.5Idempotent-ish habits — check before install
- 5.6Cron basics — schedule the script
- 5.7Secrets — never hardcode
- 5.8Reading arguments and a full sample script
- 5.9Functions — keep scripts readable
- 5.10Debugging scripts without guessing
- 5.11Lab — health check script with dry-run
The chapter recap is at the end of the last concept page.