Home / Bash
Bash
Bash beyond the basics: deeper grep, sed and awk, parameter expansion in depth, processes and jobs, and robust scripts with strict mode, logging and debugging. Every example is verified with the real shell.
Basic Bash gets a job done once. Intermediate Bash gets it done safely every time, even when a file is missing, the input is strange, or a command in the middle fails. This course takes the scripts from the Beginner course and hardens them: sharper text tools, deeper parameter tricks, real process control, and scripts that check their own work.
Course contents
Work top to bottom — the sidebar is the course. Topics later in the list assume the ones before them.
Bash Intermediate Introduction
Intermediate · ⏱ 4 min · standalone lesson
Text Processing in Depth
- Bash Grep Extended Patterns
- Bash Grep Perl Patterns
- Bash Sed Addressing
- Bash Sed Substitution
- Bash Sed Scripts
- Bash Awk Fields and Formatting
- Bash Awk Patterns and Counting
- Bash Awk Functions
Shell Parameters in Depth
- Bash Parameter Defaults
- Bash Parameter Trimming
- Bash Parameter Substitution
- Bash Parameter Case Changes
- Bash Parameter Substrings and Length
Functions and Scope
- Bash Function Return Values
- Bash Function Scope
- Bash Function Libraries
- Bash Nested Command Substitution
Processes and Jobs
- Bash Process Substitution
- Bash Pipelines and Pipefail
- Bash Subshells and Grouping
- Bash Job Control
- Bash Signals and Traps
Arrays in Depth
Start: Bash Array Slicing ❯Robust Scripts
- Bash Strict Mode
- Bash Error Handling
- Bash Logging
- Bash Argument Parsing with Getopts
- Bash Config Files
Debugging
Start: Bash Input Validation ❯Files and Streams in Depth
- Bash Advanced Redirection
- Bash Tee and Streams
- Bash Safe Temporary Files
- Bash Eval versus Arrays
- Bash Find with Exec
Everyday Tools
Start: Bash Xargs ❯Bash Project: Log Analyzer
Intermediate · ⏱ 6 min · standalone lesson
Bash Project: Backup Script
Intermediate · ⏱ 6 min · standalone lesson
Learn Bash Intermediate
Bash Intermediate is the point where scripts stop being short recipes and start being small programs. A ten-line script can ignore most failures and still look fine. A hundred-line script cannot: one unchecked filename, one empty variable, or one failed pipe can quietly corrupt the result. This course teaches the habits and the tools that keep longer scripts honest.
Four threads run through the course. Text processing goes deeper: extended and Perl-style grep patterns, sed addressing, substitution and full scripts, and awk fields, patterns and functions for shaping columns and counting. Shell parameters go deeper too: defaults, trimming, replacement and case changes that replace whole chains of small commands. Then come processes and jobs: process substitution, pipeline statuses, background jobs, signals and traps, and the difference between a subshell and a group.
The last thread is the one that matters most in real work: writing scripts that fail loudly instead of silently. Strict mode with set -euo pipefail is taught with its honest limits, not as a magic line. Error handling, logging, option parsing with getopts, config files and input checks follow, and a debugging group shows how to trace a failing script with set -x and trap DEBUG instead of guessing.
Forty-six lessons in ten groups build toward two finished projects: a log analyzer that counts and ranks real log lines, and a backup script with a dry-run mode and a guard against backing up into its own source. Each example was executed with the genuine shell while the lesson was being written, so what you read is exactly what the script printed.
What you will learn
Follow the groups in order, and by the final project these Bash skills are yours:
- Search text with extended grep patterns and Perl-style patterns with lookarounds.
- Address, substitute and script edits with sed, including hold space for multi-line work.
- Shape columns, format output and count with awk fields, patterns and functions.
- Set defaults, trim prefixes and suffixes, replace text and change case with parameter expansion.
- Return results from functions cleanly and share code through sourced libraries.
- Compare command outputs with process substitution and read pipeline failures with pipefail and PIPESTATUS.
- Run jobs in the background, wait for them, and clean up with traps on EXIT and ERR.
- Slice arrays, count with associative arrays, and load files with mapfile.
- Write strict scripts with set -euo pipefail, and know exactly where strict mode stops protecting you.
- Handle errors, log progress, parse options with getopts, and read config files with a clear override order.
- Trace a failing script with set -x and trap DEBUG, and dodge the quoting and word-splitting traps.
- Redirect file descriptors, split streams with tee, make safe temporary files, and finish with a log analyzer and a backup script.
Who this Bash Intermediate course is for
This course assumes the Beginner course. Variables, tests, loops, functions, arrays, and first looks at grep, sed and awk are used from the first lesson and are not taught again. If you have not taken it, start there: the Intermediate lessons will feel like they skip steps, because they do.
It fits anyone whose scripts have grown past twenty lines and started breaking in ways that are hard to explain. If a script works on your machine and fails on a server, or a loop silently processes the wrong files, the debugging and strict-mode groups name the exact mechanisms behind those failures.
Total lesson time is four hours and seven minutes, the sum of the per-lesson estimates across all forty-six lessons. The text-processing group is the longest stretch, and the robust-scripts group is the one working scripters return to most.
How this course works
Work top to bottom. Each group builds on earlier ones: parameter tricks need variables, job control needs processes, and the backup project needs nearly everything.
Every lesson is short. It opens with a definition, shows two to four small examples, closes with one full program, and ends with an exercise whose answer comes with the reason for it.
Each example was executed with the genuine shell while the lesson was being written. Outputs on the page are outputs the script truly printed, including the error exhibits, which quote real error lines in full.
Progress is saved in your browser as you finish lessons, so the course home always shows where you left off and the next lesson to open.
Frequently asked questions
Do I need to finish Bash Beginner before this course?
Yes. This course uses variables, tests, loops, functions, arrays, and first looks at grep, sed and awk from the first lesson, and it does not re-teach them. Take the Beginner course first if any of those feel new.
Is this Bash Intermediate course free?
Yes. There is no account, no paywall, and no trial clock. Every lesson, exercise and project is open to read and work through.
Do I need a Linux machine to follow along?
You need a Bash shell. The examples run on the Bash found on Linux and macOS. On Windows, they run inside a Linux environment such as WSL.
How long does the course take?
Counted lesson by lesson, the course runs four hours and seven minutes, before practice time. Working through the exercises and rewriting the projects in your own words takes longer, and that extra time is where the habits form.
Does the course really teach set -euo pipefail, limits included?
Yes, and the limits are the point. The strict-mode lesson shows what each flag does, then shows where strict mode stays silent: failing commands inside if-conditions, after and-or lists, and other spots where the shell deliberately does not stop. A guard you trust blindly is worse than no guard.
What can I build after this course?
Log analyzers that count and rank real log lines, backup scripts with dry-run modes and safety guards, deployment glue that checks its inputs before touching anything, and scheduled jobs that log what they did and fail loudly when they cannot.
Next steps
- Bash ❯ — The prerequisite course: variables, tests, loops, functions, arrays, and first looks at grep, sed and awk.
- PowerShell ❯ — The same scripting ideas on Windows: variables, pipelines, functions and objects, taught from first print.