Bash Parameter Expansion Explainer

Paste a shell expansion and a sample value to see exactly what it produces and why.

from ${ to }; the variable name may be anything
the value that name holds in this example

Bash replaces ${...} before the command runs. The variable name is only a label here: the expansion is always evaluated against the value you type. Supported operators are the plain value, ${#v} for length, ${v:-word}, ${v-word}, ${v:=word}, ${v=word}, ${v:+word}, ${v+word}, ${v:?word} and ${v?word}, the offsets ${v:offset} and ${v:offset:length}, prefix removal with ${v#pattern} and ${v##pattern}, suffix removal with ${v%pattern} and ${v%%pattern}, the substitutions ${v/pattern/repl} and ${v//pattern/repl}, and case conversion with ${v^}, ${v^^}, ${v,} and ${v,,}. Patterns use shell globbing: *, ?, character classes such as [a-z] or [!0-9], and \ to escape a character. Quotes are treated as ordinary characters, not removed, and patterns are case-sensitive. A negative offset counts from the end of the value and, as in bash, needs a space after the colon so it is not read as a default word. Command substitution, nested expansions, arrays and attribute operators such as ${v@Q} are rejected rather than guessed. Length and the offset arithmetic count Unicode characters, not bytes, and case conversion uses Unicode case mapping rather than the shell's locale. This is an interactive model of bash's own rules; it does not run a shell. Everything runs locally in your browser with no storage, uploads or network access.