🎓 A1Learner
🔍
0 of 45 lessons completed

Home / Bash

Bash

Bash at expert level: coprocesses and FIFOs, file descriptors in depth, traps, performance proved by counting, security against hostile input, jq and safe parsing, testing and packaging, plus three finished projects. Every example is verified with the real shell.

Intermediate Bash made your scripts safe. Advanced Bash makes them expert: processes you steer by hand, file descriptors you open and close on purpose, traps that clean up after every exit, and scripts that stay fast and stay honest when the input turns hostile. This course assumes the Beginner and Intermediate courses are done, and it builds straight on top of them.

Start learning ❯❯45 lessons · 11 topics · 0/45 completed

Course contents

Work top to bottom — the sidebar is the course. Topics later in the list assume the ones before them.

Bash Advanced Introduction

Advanced · ⏱ 6 min · standalone lesson

Advanced Processes

Start: Bash Coprocesses ❯

File Descriptors in Depth

Start: Bash Custom File Descriptors ❯

Traps in Depth

Start: Bash Trap on Exit and Cleanup ❯

Performance

Start: Bash Builtins Versus External Commands ❯

Security

Start: Bash Injection Safe Input ❯

Parsing and Data

Start: Bash jq Basics ❯

Testing and Packaging

Start: Bash Test Functions ❯

Bash Project: Test Harness

Advanced · ⏱ 7 min · standalone lesson

Bash Project: Parallel Runner

Advanced · ⏱ 7 min · standalone lesson

Bash Project: Deploy with Rollback

Advanced · ⏱ 7 min · standalone lesson

Learn Bash Advanced

Bash Advanced is the point where a script stops being a helper and starts being a tool other people rely on. A script that runs a backup at night, deploys a website, or fans work out across parallel jobs cannot afford a silent failure, a leaked descriptor, or a filename that breaks the loop. This course teaches the mechanisms that keep such scripts correct: not more commands, but deeper control over the ones you already know.

The first thread is processes and descriptors. Coprocesses hold a two-way conversation with a background program. Named pipes move data between stages that never share a command line. Wait with the -n flag runs a fixed number of jobs at once and frees each slot the moment its job finishes. Process groups let one signal stop or continue a whole job tree, and detached jobs keep working after the terminal closes. Beside them sit the descriptors themselves: custom numbers for separate streams, duplication for saving and restoring standard output and error, whole-script redirection with exec, descriptors passed into functions, clean closes, and standard error split away from standard output.

The second thread is traps, speed, and safety. Traps on EXIT, ERR and DEBUG are taught as a system: cleanup that runs on every exit path, error traps with their real scope limits, debug traps that trace with PS4, inheritance into functions and subshells, and handlers that reset themselves after one firing. Speed is proved, never guessed: every performance claim in the course is shown by counting external calls, because wall-clock timings change from run to run and prove nothing. Safety gets the same honest treatment: injection attacks are shown working and then fixed, filenames with spaces and newlines are handled with null-delimited reads, globbing surprises are disarmed, the environment is scrubbed before untrusted code runs, and noclobber and pipefail are taught with the edge cases where they stay quiet.

The last thread turns the mechanisms into finished work. JSON is read, filtered and reshaped with jq. CSV is parsed without breaking on quoted commas, binary data is handled without pretending a shell string can hold a null byte, and fixed-width columns are cut cleanly. A testing group builds test functions, assert helpers, TAP output and fixtures, then a packaging group turns shared code into libraries with version flags. Forty-five lessons in eight groups end in three projects: a test harness that runs checks and prints a TAP summary, a parallel runner that drains a slot pool and collects failures without stopping, and a deployment script that stages, backs up, and rolls back when a step fails.

What you will learn

Take the groups from first to last, and the final project will ask for all of these:

  • Hold two-way conversations with background programs using coprocesses, and move data through named pipes.
  • Run a fixed pool of parallel jobs with wait -n, steer process groups with one signal, and detach jobs that outlive the terminal.
  • Open custom file descriptors, duplicate them to save and restore output and error, redirect a whole script with exec, and close descriptors cleanly.
  • Clean up on every exit with EXIT traps, catch errors with ERR traps, trace with DEBUG traps, and control how traps pass into functions and subshells.
  • Prove performance claims by counting external calls, dodge hidden subshells, and replace per-line external commands with parameter expansion.
  • Stop injection attacks, handle hostile filenames, disarm globbing surprises, scrub the environment, and apply noclobber, pipefail and umask with their edge cases known.
  • Read, filter and reshape JSON with jq, parse CSV safely, handle binary data within its honest limits, and cut fixed-width fields.
  • Write test functions with assert helpers, emit TAP output, isolate tests with fixtures, package shared code as libraries, and ship scripts with version flags.
  • Finish with three working programs: a TAP test harness, a parallel task runner with failure collection, and a deployment script with rollback.

Who this Bash Advanced course is for

This course is for people who already write Bash and want to write it at a professional standard. If you maintain deployment scripts, backup jobs, build glue, or scheduled tasks that run while nobody watches, the traps, descriptors and hardening habits here are the difference between a script that usually works and one you can trust.

You should arrive with the Beginner and Intermediate courses finished, or with the same ground covered elsewhere: variables, tests, loops, functions and arrays, grep, sed and awk at a working level, parameters in depth, process substitution, job control, strict mode and its limits, and debugging with set -x. Nothing in this course re-teaches that ground; new ideas are introduced on the assumption that the earlier ones are already yours.

If any of that feels new, take the Intermediate course first. The Advanced lessons move fast, and they spend their time on mechanisms and edge cases rather than on foundations.

How this course works

The course runs from the first lesson to the last project in one line, and each group assumes the ones before it. Lessons are short, usually between four and seven minutes of reading, and each one closes with an exercise, and the answer explains why it is right rather than only naming the letter.

Every code block on the page was executed with the genuine shell before publication, and the output shown is the output the program printed. Where a claim is about speed, the page shows a count of external calls instead of a timing, because a timing from one machine on one day would not reproduce on yours. Where a lesson shows an attack, the attack runs for real and the fix runs right beside it, so you can see both outcomes instead of taking either on trust.

Progress is kept in your browser as you complete lessons, and the course home shows how far through the forty-five lessons you are. There is nothing to install beyond a Bash shell and jq, both covered in the early lessons, and every example is written to run on Linux and macOS, or inside a Linux environment on Windows.

Frequently asked questions

Do I need to finish Bash Intermediate before this course?

Yes. This course builds directly on it: parameters in depth, process substitution, job control, strict mode with its limits, and debugging with set -x are all treated as known. The Beginner course sits underneath that. If any of those feel new, work through Intermediate first and come back.

Is this Bash Advanced course free?

Yes. You can read every lesson, try every exercise, and build all three projects without creating an account or passing a payment step.

How long does the course take?

Adding up the per-lesson estimates gives four hours and twenty minutes of reading, before practice time. The three projects take longer than their reading time suggests, because adapting them to your own jobs is where the expert habits actually form.

Do I need to install anything special?

You need a Bash shell and jq. Both are standard on Linux and macOS. On Windows, use a Linux environment such as WSL: both tools are standard there. No other tool is required: the testing group builds its harness from plain shell functions, with no test framework to install.

Why does the course never show timings for its speed claims?

Because a timing measured once does not reproduce. The same loop can take twice as long on a loaded machine, so a printed timing would teach nothing reliable. Instead each performance lesson wraps the external command in a counting function, and the page shows exactly how many times it ran. A count is the same on every machine.

What can I build after this course?

Scripts that other people can run without you in the room: parallel runners that drain a job pool and report failures, deployment scripts that roll back when a step fails, test harnesses for your own shell code, and hardened maintenance scripts that clean up after themselves, log what they did, and refuse hostile input instead of executing it.

Next steps

  • Bash ❯ — The prerequisite course: text tools in depth, parameters, processes and jobs, robust scripts, and debugging.
  • PowerShell ❯ — The other shell on this platform: objects in a pipeline instead of text, for the same automation jobs on Windows.