- ${HOME}
$HOME
~/
What do the brackets do?
thanks,
df
Thanks Step. This makes sense. I didn't want to have the last word on this thread, but I did want to thank you.step wrote:In this case the brackets do nothing. In other cases they can serve to
1. separate the variable name from other text: ${HOME}less -> "/rootless" vs $HOMEless -> ""
2. introduce various ways to transform the variable value, i.e., ${HOME/oo/an} -> "/rant"
Note that the above discussion assumes that HOME is preset to "/root" for the root user - there can be cases when such isn't the case.
The bash shell expands ~ to the user's home directory, in this example "/root". But other shells don't do that kind of expansion, so ~ -> "~" for those shells. Bash also expands ~root to root's home directory, and more generically ~User to User's home directory for any User. Be careful relying on the ~ expansion in your scripts, because the rules for expanding ~ differ from the rules for expanding regular variables, such as HOME.