Shell command explainer
Paste a command line or a script and see it taken apart — pipes, redirections, && and ||, subshells, loops, quoting, variables, substitutions, globs and here-documents — with every option of 170 common commands explained, warnings for dangerous patterns such as rm -rf $DIR/ and curl | sh, and ShellCheck-style notes on common mistakes.
Added
Works with
- Linux shell playground Linux and macOSTry it copies the command and opens a real shell to paste it
How to use it
Paste a command you found in a README or a Stack Overflow answer, or one you are about to run, and
this page parses it the way bash would and explains each piece: which command runs, what each
option does, where its input comes from and its output goes, and what the shell does to each word
before the command ever sees it (quotes, $variables, $(command substitution), globs, ~ and
{a,b} brace expansion).
The parser is written for this page and runs in your browser. It understands pipelines, && and
||, ; and &, ( subshells ) and { groups; }, if / elif / else, for (both forms),
while, until, case, functions, [[ … ]] and …, every kind of redirection including
2>&1, &>, here-documents (<<EOF, <←EOF, quoted markers) and here-strings, and process
substitution <( … ).
How to use it
Type or paste into the box; the explanation updates as you type. The command is shown again coloured by part — the command, its options, their values, redirections, variables, quoting, substitutions and globs. Hover over a part to find its explanation in the tree, or over an explanation to see which characters it covers.
Options are matched against a dataset of 170 commands that I wrote for this page — the file and
text tools (ls, find, grep, sed, awk, sort, uniq, cut, tr, xargs …), archives,
networking (curl, ssh, rsync, dig, ss), processes (ps, kill, pkill), permissions,
systemctl and journalctl, package managers, and the subcommands of git, docker, kubectl,
apt, npm and others. Grouped short options (tar -xzvf, ps aux), values attached or separate
(-n5, -n 5, --lines=5), -NUMBER forms (head -20, kill -9), -- and find -exec … \;
are all handled; commands such as sudo, xargs, env, nohup and timeout have the command
they run explained too. A chmod mode is spelled out (755 → owner rwx, group r-x, others r-x) —
the chmod calculator does more — and so is a simple sed script. Click a
name in Commands I know to start with it.
Warnings are in three levels:
- Danger
-
things that can destroy data or run code you haven’t seen —
curl … | sh,rm -rfon a path built from a variable that might be empty (guard it with${DIR:?}),rm -rf /,ddonto a whole disk,mkfs, a file read and written by the same pipeline (sort f > fleaves it empty), and the fork bomb. - Warning
-
unquoted
$variables(split on spaces and globbed),"$@"written without quotes,for f in $(ls), parsingls,find | xargswithout-print0,2>&1 > filein the wrong order,cdwithout|| exit,sudo echo … > /root/file(the redirection isn’t run as root),git push --force,chmod 777, and switching off TLS or host-key checks. - Note
-
useless use of
cat,grep | wc -l,readwithout-r, backticks,== ` in `[ ],a && b || cas if-then-else, andlocal x=$(…)hiding the exit status.
Where a check matches one of ShellCheck's, its code links to the ShellCheck wiki page. These checks catch common mistakes; ShellCheck catches many more, so run it on anything that matters.
▶ Try it in a real Linux shell copies the command and opens the Linux
shell playground, a real kernel and BusyBox shell in the page, where you can paste and run it
safely. BusyBox’s tools have fewer options than the GNU ones, so some flags explained here won’t
exist there. To test a pattern from a grep, try the regular expression
tester; for a crontab line, the cron explainer.
Share link puts the command into the link.
What it doesn’t do
It doesn’t run anything, and it only knows what the shell does at parse time: it can’t tell what a variable will hold or whether a file exists. Aliases and functions defined elsewhere are unknown. Options that differ between GNU (Linux) and BSD (macOS) tools are described the GNU way, with the differences noted where they commonly bite. zsh- and fish-specific syntax isn’t covered.
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.