parameter-expansion

Bash ${name:-word} — default when unset or empty

Substitutes word when the parameter is unset or empty. Does not assign the fallback.

Formal Syntax & Structure

bash syntaxbash
${name:-word}

Parameters & Attributes

NameTypeDescription
name, wordstringParameter and fallback word.

Return Value

string

Parameter value or fallback.

Working Example

Example Snippetbash
label=printf '%s\n' "${label:-Guest}"label='Neda'printf '%s\n' "${label:-Guest}"
Bash Reference