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.
Three separate things
12 minstdin, stdout and stderr, and why a pipe only carries one of them.
cat wc exec
Streaming, measured
8 minA pipeline that reads the file four times is not the better answer.
head yes seq tee
Background, and the signal that is real
12 minWhat `&` leaves behind, and what this shell will not pretend.
wait jobs kill trap
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.
grep, and which regular expression
8 minBasic and extended patterns are backwards from each other.
grep
sort, and why uniq needs it
8 minuniq only collapses adjacent lines.
sort uniq
cut, and what it will not do
6 minFields, and the line with no delimiter.
cut paste
sed is a language
12 minAn address selects; a command acts.
sed
The loop awk wrote for you
12 minPatterns, actions, fields, and END.
awk
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.
Arguments and shift
12 minReading a script's own parameters without losing one.
set shift for getopts
while read, and the pipe that eats your variable
8 minEvery stage of a pipeline is a subshell.
read while
Functions, and why local matters
8 minWithout it, every assignment is global.
local return
Here-documents
8 minA block of text as input, and the one switch that matters.
cat
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.