regarding the file: .bash_profile

what is the different between




and what is the correct syntax?

  • In this case, both are equivalent – GMaster Sep 18 '16 at 10:19

I'm guessing they are both equivalent, when a variable is used in the form:


the curly braces serve to delimit the variable WORD when it would otherwise be indistinguishable from another WORD directly adjacent. e.g.

echo $HOMEahoy

would produce nothing (except the newline from the echo)

echo ${HOME}ahoy 

would echo your home path like you expect plus ahoy.
I suspect in this case the {} are unnecessary because =:/ are likely not valid variable characters in bash so, bash can work out the WORD boundaries itself.
When shell scripting, if in doubt I always put in the curly braces.
The idea is not limited to bash e.g. PHP has similar behaviours - except in PHP they take a slightly different form e.g. {$VAR_NAME}

| improve this answer | |

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