Character quotation

Many characters have a special meaning to the shell. Sometimes you want to conceal that meaning. Single (') and double (") quotation marks surrounding a string, or a backslash (\) before a single character allow you to conceal the character's meaning.

All characters (except the enclosing single quotation marks) are taken literally, with any special meaning removed. Thus, the command:
stuff='echo $? $*; ls * | wc'
assigns the literal string echo $? $*; ls * | wc to the variable stuff. The shell does not execute the echo, ls, and wc commands or expand the $? and $* variables and the asterisk (*) special character.

Within double quotation marks, the special meaning of the dollar sign ($), backquote (`), and double quotation (") characters remains in effect, while all other characters are taken literally. Thus, within double quotation marks, command and variable substitution takes place. In addition, the quotation marks do not affect the commands within a command substitution that is part of the quoted string, so characters there retain their special meanings.

Consider the following sequence:
ls *
file1 file2 file3
message="This directory contains `ls * ` " 
echo $message
This directory contains file1 file2 file3
This shows that the asterisk (*) special character inside the command substitution was expanded.

To hide the special meaning of the dollar sign ($), backquote (`), and double quotation (") characters within double quotation marks, precede these characters with a backslash (\). When you do not use double quotation marks, preceding a character with a backslash is equivalent to placing it within single quotation marks. Therefore, a backslash immediately preceding a newline character (that is, a backslash at the end of the line) hides the newline character and allows you to continue the command line on the next physical line.