· Single quotation marks, as in the preceding example , will always get you exactly what's inside the quotation marks --any characters that might otherwise have special meaning to the shell (like the dollar sign or the backslash ) are treated literally .
· Use double quotation marks when you want to assign a string that contains special characters the shell should act on.
· The backslash is used to escape (treat literally) a single character (such as $ or *) that might otherwise be treated as a special character by the shell.
Now let's look at some examples that show when to use each method of quoting.
howdy='Good Morning $USER !'
echo $howdy
Good Morning $USER !
howdy="Good Morning $USER !"
echo $howdyGood Morning hermie !
echo $howdy
Good Morning $USER !
howdy="Good Morning $USER !"
echo $howdyGood Morning hermie !
没有评论:
发表评论