Shell Scripting¶
Shell scripts turn the commands from the Linux track into repeatable automation: health checks, backups, deployment helpers, log scans, and the glue steps inside CI pipelines. This track goes from safe Bash structure to scripts you can trust to run unattended on production systems.
What You'll Learn¶
- How to structure Bash scripts safely with strict mode, functions, and traps
- How to slice logs, config files, and API output with
grep,sed,awk, andjq - How to lint, test, and debug scripts before they reach production
- How to add argument parsing, logging, locking, dry-run mode, and idempotency
Read in This Order¶
- Bash Fundamentals and Practical Scripts — shebang and strict mode, variables, conditionals, loops, functions, traps, and six real operations scripts
- Text Processing — pipelines,
grep,sed,awk,sort/uniq, andjqfor JSON - Testing, Linting, and Debugging — ShellCheck,
shfmt, Bats tests,set -xtracing, and scripts in CI - Production-Ready Scripts —
getopts, logging, exit codes, locking withflock, dry-run, idempotency, and retries
Shell or Python?¶
| Use shell when… | Switch to Python when… |
|---|---|
| You're mostly running other commands and checking their exit codes | You parse structured data beyond a quick jq filter |
| The script is under ~150 lines | You need data structures, classes, or real error handling |
| It runs on minimal hosts or containers with only a shell | You call HTTP APIs, paginate, and retry |
| It's a CI step or an entrypoint wrapper | It needs unit tests with mocks, or a proper CLI |
The Python Automation track picks up where shell stops.
Next¶
Start with Bash Fundamentals and Practical Scripts.