Toolshed

A growing library of browser tools and deep technical guides for IT professionals.

← All guides

Shell Command Syntax Explainer

For a curated set of common commands, this explains what the program itself does, what each flag and argument means for that specific program, and gives a plain-English summary of what the whole command will do — including composing a summary across an entire | pipeline (not just the last stage), correctly parsing find -exec ... {} \; as a nested command rather than misreading it as more find arguments, recognizing shell loops/conditionals (for/while/if) as structure rather than as programs, and explaining parameter expansions like ${file%.txt}.bak. chmod's permission modes are computed exactly via real bit math, not looked up. Outside the curated set, this tool says so plainly rather than guessing — and when it can't parse something reliably enough to summarize safely, it says that too instead of fabricating an answer. Runs entirely in your browser.

What this does and doesn't cover

Shell syntax (always covered): pipes (|), logical operators (&&, ||, ;), backgrounding (&), output/input redirection (>, >>, <, <<<), file-descriptor redirects (2>, 2>&1), single/double quoting, variable expansion ($VAR, ${VAR}), and command substitution ($(...), backticks).

Command semantics (covered for a curated set — chmod, chown, ls, grep, find (including -exec/-execdir), tar, cp, mv, rm, mkdir, ps, kill, curl, wget, ssh, du, df, and the common pipeline utilities cat/sort/uniq/head/ tail/cut/tr/wc/xargs/ tee/printf/echo): what the program does, what each flag means for that specific program, what role each argument plays, and a synthesized summary — of the single command, or of the whole pipeline when commands are chained with |.

Shell control structures (also covered): for/in/ do/done, while/until, if/ then/elif/else/fi, case/ esac, function, time/coproc, and { }/( ) grouping — these are recognized as shell structure, never mislabeled as external programs, and loop/conditional bodies are parsed recursively.

Parameter expansion (also covered): $VAR, ${VAR}, ${VAR:-default}, ${VAR:=default}, ${VAR:+alt}, ${VAR:?err}, ${VAR#pat} / ${VAR##pat} (shortest/longest prefix removal), ${VAR%pat} / ${VAR%%pat} (shortest/longest suffix removal), ${#VAR}, and ${VAR:offset:length} substrings — including when embedded inside a larger quoted string like "${file%.txt}.bak".

Deliberately not covered: full per-subcommand grammars for git, docker, kubectl, systemctl, npm/pnpm/yarn, cargo, go, terraform, and the major cloud CLIs (aws/gcloud/ az) — git commit and git push have completely different argument grammars from each other, so a flat flag table would produce wrong answers. These get an honest "detailed semantics not available yet" on their subcommands and flags instead of either silence or a guess (rsync is flag-based rather than subcommand-based, so it gets the same honest treatment without a false "subcommand" label). When a parse is too unreliable to summarize safely — a malformed find -exec with no terminator, for instance — this tool says the summary couldn't be generated rather than guessing at one.