Bash Scripting and Automation | Nesqual TechCourse outline
How Bash reads and runs your commands
- The shebang and four ways to run a scriptLesson30 min
- Interactive, login and non-interactive shellsLesson30 min
- The order in which Bash processes a lineLesson30 min
- What a command is: keywords, builtins, functions, aliases and filesLesson30 min
- Exit status, pipelines and compound commandsLesson30 min
- Seeing what a script does, and meeting opskitLesson35 min
- Chapter 1 quiz: how Bash worksQuiz15 min
Quoting and expansion in depth
The quoting forms and what "$@" really doesLesson30 minWord splitting and IFSLesson30 minGlobbing in depthLesson30 minBraces, tilde and the order of expansionLesson30 minParameter expansion without external toolsLesson35 minCommand substitution, arithmetic and process substitutionLesson35 minQuoting and expansion quizQuiz15 minLab: fix a script that breaks on awkward file namesLab40 minArrays and data structures
- Indexed arrays: lists that keep their shapeLesson30 min
- Associative arrays: lookups and countersLesson30 min
- Reading data into arrays: mapfile, read and CSVLesson35 min
- Building commands in arrays instead of stringsLesson30 min
- declare, readonly, namerefs and indirectionLesson35 min
- Chapter quiz: arrays and data structuresQuiz15 min
Functions and libraries
- Functions, arguments and scopeLesson30 min
- Status, output and resultsLesson30 min
- Passing and returning arraysLesson30 min
- Sourcing, libraries and the main patternLesson30 min
- Building lib/util.sh and lib/log.shLesson35 min
- Usage, help and a complete toolLesson35 min
- Quiz: functions and librariesQuiz15 min
Text processing pipelines
- Reading lines safely: read, pipes and here-documentsLesson30 min
- grep in earnest: options, exit status and conditionsLesson30 min
- sed beyond substitution: addresses, ranges and safe editingLesson30 min
- awk as a report language: fields, arrays and joinsLesson35 min
- The supporting tools: sort, join, comm, xargs and null-delimited pipelinesLesson35 min
- Assembling and testing pipelinesLesson35 min
- Text processing pipelines quizQuiz15 min
- Lab: build logsum, a log summary toolLab40 min
Error handling and traps
- What set -e does, and where it silently stopsLesson30 min
- set -u, pipefail and the ERR trap: making failures visibleLesson30 min
- Handling errors on purpose: checks, die and exit codesLesson30 min
- Traps: cleanup, signals and handlers that composeLesson30 min
- Temporary files, retries and timeoutsLesson30 min
- Failing safely: guards, destructive commands and the opskit headerLesson30 min
- Chapter quiz: error handling and trapsQuiz15 min
- Lab: make a fragile backup rotation safeLab40 min
Arguments and option parsing with getopts
- Positional parameters and the -- conventionLesson30 min
- Parsing options with getoptsLesson35 min
- Long options and the getopt programLesson30 min
- Validating input and writing usage textLesson35 min
- Configuration, precedence and standard inputLesson35 min
- One entry point with subcommandsLesson35 min
- Chapter quiz: arguments and option parsingQuiz15 min
- Lab: build the opskit command lineLab40 min
File and process handling
- File descriptors and redirection in scriptsLesson30 min
- Safe file operations: atomic writes, noclobber and permissionsLesson30 min
- Finding files and deleting them safely with find and xargsLesson30 min
- Locking: making sure only one instance runsLesson30 min
- Background jobs, wait and bounded worker poolsLesson35 min
- Process control: subshells, exec, timeouts and signalsLesson35 min
- Files and processes quizQuiz15 min
Scheduling and unattended automation
- What cron gives your scriptLesson30 min
- Cron expressions and a matcher written in BashLesson35 min
- Making a script safe to run unattendedLesson35 min
- Logging from scheduled jobs and rotating the logsLesson30 min
- Heartbeats, status files and alertsLesson30 min
- Beyond cron: systemd timers, at, anacron and loopsLesson30 min
- Scheduling and unattended automation quizQuiz15 min
Testing and linting scripts by hand
- Syntax checks and tracing: the cheapest testsLesson25 min
- Linting: shellcheck and the review checklistLesson35 min
- Writing a test harness in BashLesson35 min
- Designing for tests and stubbing commandsLesson35 min
- Golden files, Bats and shfmtLesson30 min
- Quiz: testing and linting scriptsQuiz15 min
- Lab: build a test harness and catch three hidden bugsLab40 min
Performance and portability
- Where Bash spends its timeLesson30 min
- Measuring honestlyLesson30 min
- Reading big files: loops versus one passLesson35 min
- Parallel work, and knowing when to stopLesson35 min
- POSIX sh, and the Bash-only features that break itLesson35 min
- Portable scripts, tool differences and the decision ruleLesson35 min
- Performance and portability quizQuiz15 min
- Lab: speed up a summary and port a script to POSIX shLab40 min
Capstone: the opskit toolkit and where next
- Design before code: the shape of the opskit toolkitLesson25 min
- The library layer and the dispatcherLesson35 min
- Building the backup commandLesson35 min
- Building hostcheck: validating data at the doorLesson30 min
- Reviewing and testing the toolkitLesson35 min
- Running unattended, hardening, and where nextLesson35 min
- Capstone quiz: the opskit toolkitQuiz15 min
- Lab: finish the opskit toolkitLab40 min