Free online tools to generate, calculate,
convert, format, encode, and play.
 

Bash Parameter Expansion

Define variables and test parameter expansions like ${var#pattern}, ${var:-default}, substring extraction, replacement, and more — with instant live results.


Variables

Expression

Examples:

Result


How It Works

Bash parameter expansion lets you manipulate variable values inline without external commands. This tool evaluates expansions locally in your browser using the same rules as Bash.

Default & Alternate Values
Syntax Meaning
${var:-default} Use default if var is unset or empty
${var-default} Use default only if var is unset
${var:=default} Assign default if var is unset or empty
${var=default} Assign default only if var is unset
${var:+alternate} Use alternate if var is set and non-empty
${var+alternate} Use alternate if var is set
${var:?error} Error if var is unset or empty
${var?error} Error if var is unset
Substring & Length
Syntax Meaning
${var:offset} Substring from offset to end
${var:offset:length} Substring from offset for length characters
${#var} Length of the variable value
Pattern Removal
Syntax Meaning
${var#pattern} Remove shortest match of pattern from the start
${var##pattern} Remove longest match of pattern from the start
${var%pattern} Remove shortest match of pattern from the end
${var%%pattern} Remove longest match of pattern from the end
Search & Replace
Syntax Meaning
${var/find/replace} Replace first occurrence of find
${var//find/replace} Replace all occurrences of find
${var/#find/replace} Replace if find matches the start
${var/%find/replace} Replace if find matches the end
Case Modification (Bash 4+)
Syntax Meaning
${var^} Uppercase first character
${var^^} Uppercase all characters
${var,} Lowercase first character
${var,,} Lowercase all characters

All processing happens locally in your browser — no data is sent to any server.


Embed This Util

You can embed this util on your own site as a widget. Adding ?embed=1 to the URL loads a compact version with just the tool itself; no header, menu, or documentation. Paste this snippet into your HTML:


    

Copy snippet Adjust the height to taste.



Feedback

Help us improve this page by providing feedback, and include your name/email if you want us to reach back. Thank you in advance.


Share with