Scripting Basics
Automate routine operational tasks with safe, readable Bash scripts, and recognize when a task should move to a general-purpose language.
4 objectives 6 steps about 135 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Write a Bash script that takes arguments, validates input, uses variables, conditionals, loops and functions, and returns meaningful exit codes.
- Make a script robust with strict mode, correct quoting, error traps and idempotent steps, and keep it free of ShellCheck warnings.
- Automate a recurring task (backup, cleanup or health check) that runs unattended on a schedule and logs its outcome.
- Extract fields from JSON and YAML with jq and yq, and port a script that has outgrown Bash to Python with argument parsing, HTTP calls with timeouts, error handling and exit codes.
Lesson plan
6 steps, about 135 min · 5 of 5 lessons available so far
- Anatomy of a script: shebang, arguments and exit codes Concept · 15 min
- Control flow you will actually use: tests, case, loops, functions, read and command substitution Worked example · 25 min
- Quoting, strict mode, tracing with set -x and failing loudly Worked example · 20 min
- Lab: an idempotent backup job with logging and a schedule Lab · 30 min
- Beyond Bash: jq, yq and porting a script to Python Worked example · 25 min
- Check: review and repair a fragile script Knowledge check · 8 questions
Practise it
Write a health-check script that takes a list of URLs and a disk-usage threshold as arguments, checks each URL's status and the free disk space, logs timestamped results, exits non-zero on any failure, passes ShellCheck without warnings, and runs every five minutes from a systemd timer or cron; then read the URL list from a YAML file with yq and port the URL checks to a Python script that keeps the same arguments, log format and exit codes.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own Command-Line ToolIntro · 3–8 h
- Build your own Build SystemIntermediate · 4–8 h
- Build your own CI SystemIntermediate · 8–16 h
References
Hard prerequisites
Unlocks
On these roadmaps
Progress and evidence for this skill are shared across all of them.