Skip to content

Seven tracks

Learn the shell by driving one

Every claim in a lesson is a command you can run, in a terminal beside the prose, on the same engine the tests are held to. Nothing here can reach a real disk.

Quoting and expansion

What did the shell actually run?

The eight stages in order, each shown expanding live. Almost every surprising shell behaviour is a consequence of this order, and this is where you learn to read it.

Exit codes and errors

How does a script know something went wrong?

$?, && and ||, set -e and the six places it does not fire, and why set -euo pipefail is a good default rather than a safety net.

Pipes and streams

Where does the output actually go?

Three separate streams, streaming measured rather than assumed, SIGPIPE, tee, and why cat file | grep x is a habit rather than a technique.

Text processing

How do you get the answer out of a file?

grep and its families, cut and paste, sort and its stability, uniq needing sorted input, and tr.

Files and finding

What is a file, really?

find predicates and their order, filenames containing spaces and leading dashes, permissions and what the execute bit means on a directory, and symlinks versus hard links.

Scripting

How do you write one somebody else can read?

Arguments and shift, functions and local, while read and why it loses the variable on the right of a pipe, here-documents, and idempotence.

Reading a script before you run it

What will this do to my machine?

The track the rest exists for. You are given a script an agent produced and asked what it will do — before it runs. Then you run it and watch.

24 lessons. Everything you do is stored in this browser and nowhere else.