DevTools Logo

Bash Playground

Bash Playground

Run a small shell subset locally with seeded files, stdin and visible step limits.

Runs in your browser
1 command(s) detected
Try an example

Script

2 lines · 62 chars

No interactive TTY: read consumes the stdin box above when shown.

Terminal

not run yet

Run complete. The tagged terminal is shown below.

Exit code: 0

No output.

Streams are tagged; the mini-shell never executes on a host.

Virtual files (session only)

2026-01-01 INFO starting service
2026-01-02 ERROR disk almost full
2026-01-03 WARN retry queued
2026-01-04 ERROR connection reset
2026-01-05 INFO shutdown complete

What this sandbox cannot do

  • No network sockets: curl, wget and ssh are reported as unavailable.
  • No host filesystem: only the seeded in-memory files and your imports exist.
  • No fork/exec, signals or job control; functions run synchronously.
  • A step budget bounds every run (10 s equivalent by default).
  • Output is capped; the full result is never buffered without limit.

Bash Playground interprets a documented subset of shell syntax entirely in your browser: variables, echo and printf, cat, grep, wc, head, tail, sort, uniq, cut, tr, a one-field awk, test, read, simple functions and pipes. Seed files are available in a session-only virtual filesystem, stdin can be supplied, and every run shows tagged stdout/stderr plus the exit code. It is deliberately not a real bash binary or WASI sandbox: no network, no host files, no fork/exec or job control, and a step budget bounds each run. The UI states those limits before you run anything.

Examples

Count errors

Input
grep -c ERROR app.log
Output
2

The seeded log has two ERROR lines; the exit code is 0 because matches were found.

CSV name report

Input
cat data.csv | awk -F, '{print $2}' | sort | uniq -c
Output
1 Ada
1 Grace
1 Linus

A three-stage pipeline shows that pipes carry lines from one command to the next.

Exit-code branches

Input
test -f missing && echo yes || echo no
Output
no

test fails, so the && branch is skipped and the || branch runs.

About this tool

Bash Playground runs a documented subset of shell syntax in your browser: variable assignments, echo and printf, pipes, grep, awk, sort, uniq, cut, tr, head, tail, wc, test, read and simple functions.

Three seeded files (app.log, data.csv and notes.txt) live in a session-only virtual filesystem. You can import a small file, run a script against it and switch between files without leaving the tab.

This is intentionally a mini-shell, not a bash binary or a full WASI sandbox. There is no network, no host filesystem, no fork/exec and no job control. A step budget bounds every run, and the terminal tags stdout, stderr and system notices so you can see exactly what happened.

What this tool does not do

  • This is a step-bounded interpreter, not bash; advanced syntax, globbing and redirections are out of scope.
  • No network sockets, host filesystem access, signals, job control or fork/exec.
  • The virtual filesystem is session-only and files are capped in size.
  • Large output is truncated with a notice instead of being buffered without limit.
  • Branches with complex nesting are simplified compared with a real shell.

How to use this tool

  1. Write a script

    Use the editor or pick an example chip. Multi-line scripts, comments, variables and simple functions are supported.

  2. Add stdin if needed

    Turn on the stdin box for read commands and piped input; there is no interactive TTY.

  3. Import a file (optional)

    Use Import file to add your own data to the virtual filesystem, then reference it by name in the script.

  4. Run and read the terminal

    Choose Run script. Streams are tagged, the step count and exit code are shown, and failures include an explanation.

Use cases

Verify a one-liner

Check quoting, field handling and exit codes before adding a snippet to CI.

Teach shell concepts

Demonstrate pipes, expansion and branching with observable, seeded inputs.

Munge a sample log

Apply grep/awk/sort/uniq chains to a small log you import for the session.

Supported commands

CommandBehavior
echo / printfPrint literal text with $VAR expansion; printf handles \n and %s/%d
cat / grepRead virtual files; grep supports -c and -i and uses piped input when no file is given
wc / head / tail-l, -w, -c counts and first/last line slicing (-n N)
sort / uniqSort lines; uniq -c prefixes a count to each run
cut / tr / awkField extraction, character translation and a single-field awk print
test / read / exitFile-existence checks, stdin reads and explicit exit codes

Everything else fails with an explicit command-not-found message; network commands fail with exit 127.

Common mistakes

Mistake:Expecting a complete Linux environment.

Fix:Use a local terminal for real bash; this tool covers a small, documented subset and says so in-page.

Mistake:Assuming curl or wget can reach the internet.

Fix:Sockets are unavailable; network commands return exit 127 with a notice.

Mistake:Using interactive prompts without stdin.

Fix:Enable the stdin box: read consumes its first line, and an empty stdin ends immediately.

Mistake:Expecting traps to fire on cancellation.

Fix:There is no process to signal; the step budget simply stops interpretation.

Mistake:Relying on command substitution.

Fix:$() and backticks are displayed as text rather than evaluated.

Frequently asked questions

Is this a real bash shell?

No. It is an offline, step-bounded interpreter for a documented subset: variables, echo/printf, pipes, grep, wc, head, tail, sort, uniq, cut, tr, a single-field awk, test, read, exit and simple functions. Anything outside that subset reports an error instead of silently doing the wrong thing.

Can scripts access the network?

No. Network commands such as curl and wget return exit 127 with an explicit sandbox notice. Nothing is downloaded and no socket is opened by the script.

Can a script modify my computer?

No. Files live in a session-only in-memory table seeded with app.log, data.csv and notes.txt. Imported files stay in the tab and disappear when the session ends; there is no host filesystem access.

How do stdin and read work?

Enable the stdin box and type the input you want consumed. read takes the first line, and piped commands use those lines when no filename is supplied. There is no interactive TTY, so an empty stdin simply reaches EOF.

Is there a timeout?

Yes. Each run has a step budget derived from the chosen 5, 10 or 30 second limit. When it is exhausted the run stops, partial output is kept, a system notice is added and the exit code becomes 124. No process is killed because no process is started.

Why do my traps never fire?

Signals and job control are not available in the mini-shell. The tool stops interpretation at the step budget; EXIT traps are parsed but never executed, which is stated in the sandbox card.

References & standards