How to set an environment variable question

Nils Kassube kassube at gmx.net
Sun Jan 22 21:57:54 UTC 2012


Ioannis Vranos wrote:
> I have seen 2 versions for the following:
> 
> export PATH=$PATH:/some_directory
> 
> and
> 
> export PATH=${PATH}:/some_directory
> 
> 
> Is anyone of them better than the other? Or in other words, are '{'
> and '}' redundant? (I don't know shell programming).

In this case there is no difference. Braces are useful if you want to 
mix variables and text. Try this to see the difference:

a=hell
echo $ao
echo ${a}o

The first echo command has no output because the variable "ao" is 
undefined (unless you have set it for some reason). The second echo 
command uses the contents of variable "a" and appends an "o".


Nils




More information about the ubuntu-users mailing list