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


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
  • +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
  • 1
    barbar? (6more) – VxJasonxV Sep 13 '10 at 16:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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