Learning Hub › Bash 8 Hours
Bash 8-Hour Interactive Crash Course
For Senior Cloud Engineers · Shell Mechanics → Variables and Control Flow → Functions and Modularization → Error Handling and Defensive Scripting → Text and Data Processing → Ops Automation → Testing, Debugging and Portability → Production Issues and Interviews (optional) · 8 lessons × 1 hour, running through the opsctl project
Bash 5.3ShellCheckbats-corejq / yqRunning project: opsctlVerified 2026-11-17
Learning path:
← Linux 8 hours
① How Bash Works: Command Line and Shell Mechanics
② Variables, Data and Control Flow
③ Functions, Scope and Modular Scripts
④ Robustness: Error Handling and Defensive Scripting
⑤ Text and Data Processing
⑥ Automation in Practice: Ops Scripts and Cloud CLIs
⑦ Testing, Debugging, Quality and Portability
⑧ 50 Production Issues + 50 Interview Questions (optional)
Next course: Git 8 Hours →
8 lessons
Hour 1How Bash Works: Command Line and Shell MechanicsWhat a shell is: interactive vs. script, startup files and shebang; kinds of commands: builtins, keywords, functions, aliases and external commands; quoting: single quotes, double quotes, $'…' and escapes; the seven expansion steps and their order; redirection and file descriptors; pipes; exit status and && / ||; variables, environment and subshells; your first script: from the command line to an executable fileBash 5.3 · GNU coreutils
Hour 2Variables, Data and Control FlowParameter expansion: defaults, trimming, replacement and length; arithmetic: $(( )), let and integer pitfalls; arrays and associative arrays; conditionals: [[ ]], test and case; loops: for, while, until and loop control; reading input safely: read -r, IFS and mapfile; here documents, here strings and process substitution; control flow practice: a log statistics toolParameter expansion · Arrays · [[ ]] · read
Hour 3Functions, Scope and Modular ScriptsFunctions: definition, arguments and return values; scope: local, dynamic scope and global variables; output and return: command substitution, return and nameref; modularization: source, library files and naming conventions; argument parsing: getopts and long options; subcommand-style CLI design: usage, help and exit code conventions; configuration: config files, environment variables and precedence; opsctl v0.1: a maintainable script skeletonFunctions · local · nameref · getopts
Hour 4Robustness: Error Handling and Defensive ScriptingStrict mode: the real behavior and pitfalls of set -e, -u and -o pipefail; trap: EXIT, ERR, INT and cleanup; temporary files and directories: mktemp and safe cleanup; concurrency and locking: flock and idempotency; logging and observability: log functions, levels and stderr; retries, backoff and timeouts; security: injection, eval, glob and untrusted input; opsctl v0.2: defensive hardeningset -euo pipefail · trap · mktemp · flock
Hour 5Text and Data Processinggrep and regular expressions; sed: substitution, addresses and in-place editing; awk: fields, patterns and aggregate reports; find, xargs and safe handling of filenames; sorting and set operations: sort, uniq, join, comm, cut, paste; JSON and YAML: jq and yq; the limits of CSV and structured data; opsctl logs: log analysis reportsgrep · sed · awk · find · jq · yq
Hour 6Automation in Practice: Ops Scripts and Cloud CLIsCalling HTTP APIs: curl, status codes, retries and pagination; scripting cloud CLIs: --query, --output and jq with az and aws; bulk operations: parallel execution and SSH loops; deployment scripts: health checks, rollback and atomic switchover; backup and rotation scripts; scheduled execution: cron and systemd timers; running scripts in CI: GitHub Actions / GitLab CI; opsctl v0.3: health, backup and deploycurl · az · aws · systemd timer · CI
Hour 7Testing, Debugging, Quality and PortabilityDebugging: set -x, PS4, BASH_XTRACEFD and caller; static analysis: ShellCheck rules and suppression; formatting and style: shfmt and style guides; testing: bats-core, assertions and test doubles; performance: avoiding subshells, preferring builtins and profiling; portability: POSIX sh, dash, Bash 3.2 on macOS and BusyBox; when not to use Bash: signs it's time to move to Python / Go; opsctl v1.0: testing, CI and releasebats-core · ShellCheck · shfmt · set -x
Hour 8 · Optional50 Production Issues + 50 Interview QuestionsQuoting, expansion and variables, control flow, input and text processing, error handling, signals and concurrency, environment, portability, CI and security, shell mechanics and basics, script design and data processing, robustness, testing and debugging, real-world scenarios and code reviewBash 5.3
The progress bars on the cards show each lesson's learning progress saved in this browser (hidden if the browser blocks local storage).
Full outline and time allocation (7 × 1 hour + optional Hour 8)
| Lesson / Module | Time | Topic |
|---|---|---|
| Hour 1 · How Bash Works: Command Line and Shell Mechanics (Open) | ||
| 1-0 | Pre-class | Environment setup (Bash 5.x lab environment and ~/bashlab) |
| 1-1 | 00–06 | What a shell is: interactive vs. script, startup files and shebang |
| 1-2 | 06–13 | Kinds of commands: builtins, keywords, functions, aliases and external commands |
| 1-3 | 13–21 | Quoting: single quotes, double quotes, $'…' and escapes |
| 1-4 | 21–28 | The seven expansion steps and their order |
| 1-5 | 28–35 | Redirection and file descriptors |
| 1-6 | 35–42 | Pipes, exit status and && / || |
| 1-7 | 42–50 | Variables, environment and subshells |
| 1-8 | 50–60 | Your first script: from the command line to an executable file |
| Hour 2 · Variables, Data and Control Flow (Open) | ||
| 2-0 | Pre-class | Bridge and warm-up (sample dataset) |
| 2-1 | 00–06 | Parameter expansion: defaults, trimming, replacement and length |
| 2-2 | 06–13 | Arithmetic: $(( )), let and integer pitfalls |
| 2-3 | 13–21 | Arrays and associative arrays |
| 2-4 | 21–28 | Conditionals: [[ ]], test and case |
| 2-5 | 28–35 | Loops: for, while, until and loop control |
| 2-6 | 35–42 | Reading input safely: read -r, IFS and mapfile |
| 2-7 | 42–50 | Here documents, here strings and process substitution |
| 2-8 | 50–60 | Control flow practice: log statistics tool |
| Hour 3 · Functions, Scope and Modular Scripts (Open) | ||
| 3-0 | Pre-class | Prep: opsctl project skeleton |
| 3-1 | 00–06 | Functions: definition, arguments and return values |
| 3-2 | 06–13 | Scope: local, dynamic scope and global variables |
| 3-3 | 13–21 | Output and return: command substitution, return and nameref |
| 3-4 | 21–28 | Modularization: source, library files and naming conventions |
| 3-5 | 28–35 | Argument parsing: getopts and long options |
| 3-6 | 35–42 | Subcommand-style CLI design: usage, help and exit code conventions |
| 3-7 | 42–50 | Configuration: config files, environment variables and precedence |
| 3-8 | 50–60 | opsctl v0.1: a maintainable script skeleton |
| Hour 4 · Robustness: Error Handling and Defensive Scripting (Open) | ||
| 4-0 | Pre-class | Prep: failure scenario scripts |
| 4-1 | 00–06 | Strict mode: the real behavior and pitfalls of set -e, -u and -o pipefail |
| 4-2 | 06–13 | trap: EXIT, ERR, INT and cleanup |
| 4-3 | 13–21 | Temporary files and directories: mktemp and safe cleanup |
| 4-4 | 21–28 | Concurrency and locking: flock and idempotency |
| 4-5 | 28–35 | Logging and observability: log functions, levels and stderr |
| 4-6 | 35–42 | Retries, backoff and timeouts |
| 4-7 | 42–50 | Security: injection, eval, glob and untrusted input |
| 4-8 | 50–60 | opsctl v0.2: defensive hardening |
| Hour 5 · Text and Data Processing (Open) | ||
| 5-0 | Pre-class | Prep: log, CSV, JSON and YAML datasets |
| 5-1 | 00–06 | grep and regular expressions (BRE / ERE / PCRE) |
| 5-2 | 06–13 | sed: substitution, addresses and in-place editing |
| 5-3 | 13–21 | awk: fields, patterns and aggregate reports |
| 5-4 | 21–28 | find, xargs and safe filename handling |
| 5-5 | 28–35 | Sorting and set operations: sort, uniq, join, comm, cut, paste |
| 5-6 | 35–42 | JSON and YAML: jq and yq |
| 5-7 | 42–50 | The limits of CSV and structured data |
| 5-8 | 50–60 | opsctl logs: log analysis reports |
| Hour 6 · Automation in Practice: Ops Scripts and Cloud CLIs (Open) | ||
| 6-0 | Pre-class | Prep: cloud account (optional) and API sandbox |
| 6-1 | 00–06 | Calling HTTP APIs: curl, status codes, retries and pagination |
| 6-2 | 06–13 | Scripting cloud CLIs: --query, --output and jq with az and aws |
| 6-3 | 13–21 | Bulk operations: parallel execution and SSH loops |
| 6-4 | 21–28 | Deployment scripts: health checks, rollback and atomic switchover |
| 6-5 | 28–35 | Backup and rotation scripts |
| 6-6 | 35–42 | Scheduled execution: cron and systemd timers |
| 6-7 | 42–50 | Running scripts in CI: GitHub Actions / GitLab CI |
| 6-8 | 50–60 | opsctl v0.3: health, backup and deploy |
| Hour 7 · Testing, Debugging, Quality and Portability (Open) | ||
| 7-0 | Pre-class | Prep: testing and CI toolchain |
| 7-1 | 00–06 | Debugging: set -x, PS4, BASH_XTRACEFD and caller |
| 7-2 | 06–13 | Static analysis: ShellCheck rules and suppression |
| 7-3 | 13–21 | Formatting and style: shfmt and style guides |
| 7-4 | 21–28 | Testing: bats-core, assertions and test doubles |
| 7-5 | 28–35 | Performance: avoiding subshells, preferring builtins and profiling |
| 7-6 | 35–42 | Portability: POSIX sh, dash, Bash 3.2 on macOS and BusyBox |
| 7-7 | 42–50 | When not to use Bash: signs it's time to move to Python / Go |
| 7-8 | 50–60 | opsctl v1.0: testing, CI and release |
| Hour 8 (optional) · 50 Production Issues + 50 Interview Questions (Open) | ||
| 8-0 | Pre-class | Instructions and failure lab environment |
| 8-1 | 00–08 | A · Quoting, expansion and variables (questions 1–12) |
| 8-2 | 08–16 | A · Control flow, input and text processing (13–25) |
| 8-3 | 16–24 | A · Error handling, signals and concurrency (26–38) |
| 8-4 | 24–30 | A · Environment, portability, CI and security (39–50) |
| 8-5 | 30–37 | B · Shell mechanics and basics (interview 1–13) |
| 8-6 | 37–44 | B · Script design and data processing (14–25) |
| 8-7 | 44–52 | B · Robustness, testing and debugging (26–38) |
| 8-8 | 52–60 | B · Real-world scenarios and code review (39–50) |
Pagination for each module
Hours 1–7: principles (What / Why / How / When) · diagrams · animations · commands · labs · production cases · troubleshooting · quizzes · English narration · videos. Hour 8: the production-issues part has overview · issue details · diagrams · animations · reproduction labs · quiz · narration · video; the interview part has overview · interview question details · diagrams · mock interview · scenario questions · quiz · narration · video. Each lesson ends with a cheat sheet, a comprehensive lab, a final quiz, and a note on sources and versions.
Lab environment
- Any Bash 5.x environment: the Linux course's lab machine
linuxlab(Ubuntu 26.04, Bash 5.3), WSL2, macOS (new Bash installed via Homebrew), or a containerbash:5.3 - Working directory
~/bashlab: sample datasets (access logs, CSV, JSON, YAML) and the running projectopsctl(evolves lesson by lesson to v1.0 starting from Hour 3) - The cloud CLI part of Hour 6 is optional (Azure / AWS); everything else is done locally at zero cost
Animations and narration: Animations are implemented with inline SVG and JavaScript and play offline; the narration pages use the browser's built-in Web Speech API (en-US) to read the lecture script aloud.
Limitations: Lab commands are written from the official documentation and have not been run step by step in a real environment; IDs, IPs and times in the expected output are sample values. The authoring environment cannot produce videos or MP3 files, so the video pages list only verified public videos with storyboard scripts; details that could not be verified are noted on each lesson’s “Sources and version notes” page.
Next course: Git 8-Hour Interactive Crash Course: put your scripts under version control and collaborate with your team.
Next course: Git 8 Hours →