Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a difference when variables are referred to as $variableName and ${variableName} in bash?

share|improve this question
up vote 2 down vote accepted

From man bash:

The basic form of parameter expansion is ${parameter}. The value
of parameter is substituted. The braces are required when
parameter is a positional parameter with more than one digit, or
when parameter is followed by a character that is not to be
interpreted as part of its name.


echo ${10}
echo ${foo}bar
share|improve this answer
+1 They're also required when referring to an array element that's not on the left hand side of an assignment. In fact they are never used on the left hand side. For scalar variables where there's no following characters that need to be set apart, the braces are optional. var=$other is equivalent to var=${other}. – Dennis Williamson Sep 13 '10 at 15:52
barbar? (6more) – VxJasonxV Sep 13 '10 at 16:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.