Please enable JavaScript eh!

 ⌘ Web Mechanic ⌘ 

Bash Scripting


Parameter Expansion $

This may be the most useful and powerful expansion you will run into.

The dollar symbol $ is used in 3 different situations:

It is typically used with curly braces { } which are optional, but strongly recommended.

If not used, the variable to be expanded from characters immediately enclosed by them, could be interpreted as part of the name

Brace expansion is used thus:

${parameter}

where parameter is replaced by its value.

value="This is not a value"
echo ${value}
This is not a value

We've seen this on the Scripting page dealing with arrays, and on the Loops page.

But there is a lot more to parameter expansion!

Command Substitution