Skip to content

Bash practice

Practice Bash online: 10 shell-scripting exercises and a playground

This runs real bash syntax and a large slice of everyday coreutils (grep, sed, awk, cut, sort, uniq, pipes and redirects) inside a simulated shell built for the browser, with its own small in-memory filesystem for a script to write and read files during a run. It is honestly not a full system shell: there is no network, no package manager, and commands like curl, ssh or gzip do not exist here — the exercises stick to what a script does with text, variables and control flow, which is most of what shell scripting actually is.

checked exercises
10
graded problems
0
lessons
0
cheat sheet (coming)
0

Bash & the Shell practice exercises

How the path works →

In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.

  1. Trail Signpostecho prints one line, and double quotes keep spacing exactly as typed
  2. Lost and FoundVariables: name=value with no spaces, $name to use it, and single quotes stop expansion
  3. Moving-Day Boxes$((...)) does whole-number arithmetic, and printf formats columns but never adds a newline
  4. Rainwater Tank Gaugeif runs a command and checks its exit status; [ ] compares numbers with -lt/-gt and needs spaces around its brackets
  5. Photo Rename Planfor loops over a word list, and ${name} braces mark where a variable name ends
  6. Downloads Tidy-Upcase matches one value against glob patterns, each branch ending in ;;
  7. Bakery Oven TimesFunctions take $1 $2 arguments, print their result, and are captured with $(...)
  8. Cabin Guest Book> creates a file, >> appends to it, and while read ... done < file reads it line by line
  9. Birdwatching TallyPipes chain sort, uniq -c, grep -c and wc -l into a tally
  10. Library Overdue ReportIFS=, read splits a comma-separated line into fields for that one read

Coding interview questions

Original questions with full model answers, for when the practice is going somewhere specific.

Questions people ask

Is this a real terminal?
No, and it says so on purpose: it is a simulated bash environment (just-bash) that understands real bash syntax and a wide set of everyday commands, running entirely inside your browser tab with an in-memory filesystem. There is no real operating system underneath, no network access, and no way to reach anything outside the sandbox.
Which commands actually work?
Variables, arithmetic, if/case, for/while loops, functions, pipes and redirects, and coreutils like echo, cat, grep, sed, awk, cut, sort, uniq, wc, head and tail. Network tools (curl, wget), compression (gzip, tar) and anything needing a real OS are not available, and the exercises are written around that honestly.
Can I use read to take input?
Yes. Whatever you type into the input box beside the editor is what read receives, one line at a time, exactly as it would from a terminal.
What comes after these exercises?
Beyond the 10 exercises, the Linux commands reference covers the wider command set with real examples, and the git commands reference does the same for everyday Git.

Practise another language

The same kind of practice hub exists for Python, JavaScript, TypeScript, Java, C++, C, C#, Go, PHP, Ruby, SQL and R.