When do we need curly braces around shell variables?
Asked 07 September, 2021
Viewed 2.9K times
  • 56
Votes

In shell scripts, when do we use {} when expanding variables?

For example, I have seen the following:

var=10        # Declare variable

echo "${var}" # One use of the variable
echo "$var"   # Another use of the variable

Is there a significant difference, or is it just style? Is one preferred over the other?

7 Answer