Quoting variable values

When you have blanks in a variable value, you need to enclose it in quotation marks. The quotation marks tell the shell to treat blanks as literals and not delimiters. Single quotation marks are more serious about this than are double quotation marks:
  • Single quotation marks preserve the meaning of (that is, treat literally) all characters.
  • Double quotation marks still allow certain characters ($, ` (back quote), and \ (backslash)) to be expanded. This is important if you want variable expansion. For example, see how the $ is handled here:
    export HOMEMSG="Using $HOME as Home Directory"
    If your home directory were set to /u/user, the following:
    echo $HOMEMSG
    would display:
    Using /u/user as home directory
    If, instead, you enclosed the variable value in single quotation marks, like this:
    export HOMEMSG='Using $HOME as home directory'
    the following line:
    echo $HOMEMSG
    would display:
    Using $HOME as home directory
    As you can see, the $ is not expanded.