Exercise path · Bash & the Shell
10 Bash & the Shell exercises, in order
From your first line to a complete program you assembled yourself. Each exercise introduces exactly one new idea, runs in this tab, and tells you in plain language what happened.
How the path works
You never start from a blank editor. Every exercise hands you a program that already runs and asks you to change or add one thing, so the first success is minutes away and the last exercise is a program you can read top to bottom and explain. The ideas arrive in this order: output and quoting, variables, arithmetic and printf, conditions and exit status, loops, pattern matching with case, functions, files and redirection, pipes and filters, putting it together.
Run is the check. There is no separate submit button: press Run, and the output is compared with what the exercise asked for. When it is not right, the feedback is a sentence about what happened — the line that differed, or what the error means — rather than a verdict. Hints come one at a time, and the answer opens only after you have run your code at least once, because reading the answer first is how you learn nothing.
Your finished exercises and the code you last had in the editor are saved in this browser, so a half-done exercise is still there tomorrow. Nothing is uploaded and there is no account.
The exercises
- Trail SignpostA neatly aligned trailhead signpost: a header, three destinations with their distances in a straight column, and a footer, printed by five echo commands.New idea: echo prints one line, and double quotes keep spacing exactly as typed
- Lost and FoundA four-line notice for a station lost-and-found desk, with the item, the place it was found and the collection desk each filled in from a variable.New idea: Variables: name=value with no spaces, $name to use it, and single quotes stop expansion
- Moving-Day BoxesA three-line moving-day estimate: rooms, total boxes, and rolls of tape at ten boxes per roll, rounded up, with the numbers lined up in a column.New idea: $((...)) does whole-number arithmetic, and printf formats columns but never adds a newline
- Rainwater Tank GaugeA two-line gauge readout for a rainwater tank: one line chosen by an if/elif/else on the level, and one line showing the exit status of a comparison run on its own.New idea: if runs a command and checks its exit status; [ ] compares numbers with -lt/-gt and needs spaces around its brackets
- Photo Rename PlanThree lines showing how each photo would be renamed to its _small version, followed by three numbered contact-sheet page lines produced with seq.New idea: for loops over a word list, and ${name} braces mark where a variable name ends
- Downloads Tidy-UpA six-line plan for tidying a downloads folder, one line per file, saying which folder each file should be moved to based on its extension.New idea: case matches one value against glob patterns, each branch ending in ;;
- Bakery Oven TimesA three-line bakery timetable saying when the sourdough, baguettes and croissants come out of the oven, each time computed by one small function and printed as HH:MM.New idea: Functions take $1 $2 arguments, print their result, and are captured with $(...)
- Cabin Guest BookA guest book built up in guests.txt, then printed back with cat, counted with wc -l, and turned into three personalised welcome lines by a while read loop.New idea: > creates a file, >> appends to it, and while read ... done < file reads it line by line
- Birdwatching TallyA summary of a birdwatching log: total sightings, number of species, number of robins, and a tally of every bird from most to least seen, each answered by a short pipeline.New idea: Pipes chain sort, uniq -c, grep -c and wc -l into a tally
- Library Overdue ReportA seven-line report: one aligned row per book with title, days overdue, fine at 25p a day and the action to take, followed by the total owed, how many books were on time, and the most overdue title found with a sort pipeline.New idea: IFS=, read splits a comma-separated line into fields for that one read
After the path
The Bash & the Shell playground is where to build something of your own, and the Bash & the Shell guide sets out a learning order for everything after the basics. Everything you can practise Bash & the Shell with on this site is gathered on the Bash & the Shell practice hub. The same path also exists in Python, JavaScript, TypeScript, Java, C++, C, C#, Go, PHP, Ruby, SQL and R.