Courses / Specialisations & media / Bash Scripting

Free courseSelf-paced

Bash Scripting

Write defensive Bash automation with dry-run mode, safe file handling, traps and Bats tests checked by ShellCheck.

  • Who it's for. Learners comfortable with the Linux command line who want to automate tasks safely.
  • Before you start. Comfort with the Linux command line from the Linux and Developer Command Line course: navigating, quoting file names, redirection, pipes, permissions, exit status and dry-run planning.
  • 33 to 55 hours of study with practice
  • 8 modules, 58 lessons
  • 3 guided projects and a final project

What you'll learn

  • Explain how Bash turns a command line into words and write scripts whose quoting is correct for spaces, empty values and glob characters.
  • Write functions, getopts option parsers, loops and conditions with documented exit statuses.
  • Build text pipelines using redirection, process substitution and standard utilities, and say when Bash is the wrong tool.
  • Make scripts safe: sandbox guard, temporary files, traps, a chosen strictness level, no eval, idempotent steps and backup before edit.
  • Test scripts with plain assertions and Bats, lint with ShellCheck, choose POSIX sh or Bash deliberately, and document the tool.

Skills you'll gain

  • Shell execution
  • Quoting
  • expansion
  • Variables
  • status
  • Conditions
  • loops
  • Functions
  • arguments
  • Text pipelines
  • Files
  • signals
  • Script testing

Tools you'll use

  • Bash
  • Bats
  • ShellCheck
  • getopts
  • Standard text utilities

Details to know

  • Certificate on completionIssued after your final project is reviewed
  • 8 module checkpointsA quiz and a practical task close each module
  • Self-pacedStudy any time; your progress is saved

How every lesson works

Each lesson follows the same four steps, so you always know what comes next.

  1. 01

    Watch & Learn

    A short animated video explains one idea at a time.

  2. 02

    Guided Practice

    Work through an example step by step and check the result.

  3. 03

    Quiz & Challenge

    Short questions check the idea has landed before you move on.

  4. 04

    Mini Project

    Build something useful from a project brief.

Learn at your own pace

This is a self-paced course. There are no live classes and no fixed timetable.

  • Start any timeStudy when it suits you. Lessons are short, so they fit around work or college.
  • Pick up where you left offYour progress is saved to your account.
  • Ask when you're stuckUse Ask Mentor inside the learning platform.

Your path in 4 phases

Each phase ends with something you have built and checked.

  1. 01

    Modules 1 to 2

    Sandbox guard and quoting probe kit

    Run scripts three ways inside a learner-owned sandbox, identify which Bash is in use, resolve command names, and read exit statuses and traces.

    You build: Sandbox guard and quoting probe kit: guard.sh, a three-way run note and a version check script in the sandbox.

  2. 02

    Modules 3 to 5

    Argument-driven tidy tool with dry run

    Covers Variables and status, Conditions and loops and Functions and arguments. Structure scripts with functions, local scope, positional parameters, getopts options, validation and a dry-run wrapper.

    You build: Argument-driven tidy tool with dry run: classify-and-count script that handles awkward names and keeps totals.

  3. 03

    Modules 6 to 7

    Safe edit tool with backup, traps and idempotence

    Compose redirection, pipelines, here-documents, process substitution and text utilities, and recognise data that Bash cannot parse safely.

    You build: Safe edit tool with backup, traps and idempotence: report pipeline script with stream-separated logs.

  4. 04

    Module 8

    Defensive Bash automation with dry-run mode and test fixtures

    Test scripts with plain assertions and Bats, lint with ShellCheck, decide POSIX sh versus Bash, document the tool and assemble the capstone.

    You build: The final project, demonstrated to a trainer.

Full curriculum

8 modules and 58 lessons, 33 to 55 hours of study

01Shell execution6 lessons, 3 to 4 hours

Lessons

  • Building the learner-owned lab directory and a path guard
  • Running a script by shebang, by bash, and by executable bit
  • Which Bash is this: versions, WSL, Git Bash and macOS
  • Builtins, functions and external programs: how a command name is resolved
  • Exit status: what the script returns and what $? remembers
  • Checking and tracing a script with bash -n and set -x

After this module you can

  • Create a sandbox directory and write a guard script that exits non-zero for any path outside it
  • Run the same script three ways and explain which interpreter reads it in each case
  • Find a syntax error without running the script and read an execution trace
02Quoting and expansion7 lessons, 3 to 5 hours

Lessons

  • Word splitting turns one value into several words
  • Single quotes, double quotes and the backslash
  • Default and required values with parameter expansion
  • Trimming and measuring values with prefix, suffix and length expansion
  • Filename expansion and what happens when nothing matches
  • Forwarding arguments faithfully with "$@" versus "$*"
  • Command substitution and arithmetic expansion

After this module you can

  • Predict how many arguments a command receives when an unquoted expansion contains spaces
  • Choose the quoting that gives a literal dollar sign, an expanded variable, or a literal quote
  • Capture a command's output into a value and compute with integers, noting trimmed newlines
03Variables and status6 lessons, 3 to 4 hours

Lessons

  • Assignment syntax and the environment boundary
  • Indexed arrays and expanding them safely
  • Associative arrays and the version they require
  • Integer arithmetic in double parentheses and with declare -i
  • Reading lines and fields with read -r and IFS
  • Designing exit statuses a caller can rely on

After this module you can

  • Assign variables without stray spaces and decide which ones child programs inherit
  • Build an array, read its elements and length, and pass it to a command without splitting
  • Define and document a status table and prove each status is reachable
04Conditions and loops7 lessons, 3 to 5 hours

Lessons

  • The test command, single brackets and double brackets compared
  • File, string and integer tests
  • if, elif, && and || as control flow
  • case statements and glob patterns
  • for loops over globs and arrays instead of ls output
  • while read loops, redirected input and the pipeline subshell
  • break, continue and loop exit status

After this module you can

  • Choose between [ ] and [[ ]] and predict how each treats an empty or spaced variable
  • Pick the correct operator for file kind, string equality and numeric comparison
  • Stop or skip iterations deliberately and read the status a loop leaves behind
05Functions and arguments7 lessons, 3 to 5 hours

Lessons

  • Defining functions and what they return
  • local variables and shared scope
  • Positional parameters, $#, and shift
  • Parsing flags with getopts
  • Option values, OPTARG and silent error mode
  • Usage text and argument validation as a first step
  • A dry-run switch that routes every action through one function

After this module you can

  • Write a function, call it, and distinguish its printed output from its return status
  • Keep function variables private with local and predict leaks without it
  • Implement a -n dry-run flag so that all state-changing steps go through a single run function
06Text pipelines7 lessons, 3 to 5 hours

Lessons

  • Redirecting standard output, error and input to files
  • Pipelines, pipefail and PIPESTATUS
  • Here-documents and here-strings for inline input
  • Process substitution for comparing and feeding command output
  • Text-processing glue with cut, sort, uniq and tr
  • Substituting and selecting with sed and awk one-liners
  • Knowing when Bash is the wrong tool for the data

After this module you can

  • Send stdout and stderr to separate files and predict the effect of redirection order
  • Read each stage's status of a pipeline and decide whether pipefail helps
  • Identify input shapes that a shell pipeline cannot parse reliably and choose a safer approach
07Files and signals8 lessons, 4 to 6 hours

Lessons

  • Temporary files with mktemp and replacing a file in one step
  • Cleaning up with trap on EXIT
  • Handling interrupts and termination signals
  • What set -e does and does not catch
  • Unset variables, pipefail and the strict-mode trade-off
  • Defensive handling of untrusted names, with no eval
  • Re-runnable scripts: idempotence and check-then-act
  • Runbook discipline: dry-run first, backup before edit

After this module you can

  • Create a private temporary file in the lab and publish results by renaming rather than editing in place
  • Register a cleanup action that runs on every exit path of the script
  • Follow a written runbook sequence of preview, backup, change and verify inside the sandbox
08Script testing10 lessons, 4 to 7 hours

Lessons

  • A plain assertion harness for scripts
  • Fixtures and throwaway test directories
  • Testing exit status and the two output streams separately
  • Writing Bats tests with run, status and output
  • Bats setup, teardown and per-test temporary directories
  • Running ShellCheck and reading its exit status
  • ShellCheck dialects, severity and justified directives
  • POSIX sh versus Bash: deciding what to depend on
  • Packaging and documenting a script for someone else
  • Capstone assembly: a defensive tool with dry-run mode and test fixtures

After this module you can

  • Build a tiny assert function and a runner that reports failures through its exit status
  • Create a fresh fixture tree for each test and remove it with a trap
  • Integrate guard, dry-run, validation, cleanup, tests and lint into one reviewed tool

What you'll build

3 guided projects along the way, then a final project.

  • Sandbox guard and quoting probe kit

    after module 2
  • Argument-driven tidy tool with dry run

    after module 5
  • Safe edit tool with backup, traps and idempotence

    after module 7

Final project

Defensive Bash automation with dry-run mode and test fixtures. Options: Log archiver; Config editor with rollback; Inbox sorter.

What you submit

Source and artifact submission: script, tests, README and evidence bundle Functional checks: dry run, real run, repeat run and hostile-name fixture all pass.

How it's reviewed

Trainer review against a weighted rubric: safety correctness quoting_and_security testing documentation explanation.

Where you'll use it

  • Write a cleanup script with a dry-run mode that shows what it would change before changing it.
  • Add a trap and a backup step so an interrupted edit script leaves files in a known state.

Roles that use these skills

  • Linux system administrator
  • DevOps engineer
  • Support engineer

Earn the certificate by building, not watching

  1. Complete the lessons and pass each module checkpoint.
  2. Build your final project and demonstrate it.
  3. OUTLEARN reviews your project and issues your certificate. It is not issued automatically.

Frequently asked questions

What should I know before starting?

The course expects Linux and the Developer Command Line or an accepted equivalent. Comfort with the Linux command line from the Linux and Developer Command Line course. A short diagnostic check is described in the entry requirements.

What do I build for the final project?

You choose one of 3 options: Log archiver; Config editor with rollback; Inbox sorter. It is reviewed by a trainer in a live demonstration.

When do I get a certificate?

Only after you build and demonstrate your live project. OUTLEARN staff issue certificates; nothing is issued automatically.

Be first in when Bash Scripting opens

Email us and we will tell you as soon as enrolment opens.

Notify me when it opens
FreeOpens soon
Notify me