Code | Description |
---|---|
${FOO%suffix} |
Remove suffix |
${FOO#prefix} |
Remove prefix |
${FOO%%suffix} |
Remove long suffix |
${FOO##prefix} |
Remove long prefix |
${FOO/from/to} |
Replace first match |
${FOO//from/to} |
Replace all |
${FOO/%from/to} |
Replace suffix |
${FOO/#from/to} |
Replace prefix |
#Substrings
Expression | Description |
---|---|
${FOO:0:3} |
Substring (position, length) |
${FOO:(-3):3} |
Substring from the right |
#Length
Expression | Description |
---|---|
${#FOO} |
Length of $FOO |
#Default values
Expression | Description |
---|---|
${FOO:-val} |
$FOO , or val if unset |
${FOO:=val} |
Set $FOO to val if unset |
${FOO:+val} |
val if $FOO is set |
${FOO:?message} |
Show message and exit if $FOO is unset |
Comments