2012年6月29日星期五

Single/double quotation marks in linux shell


· Single quotation marksas in the preceding examplewill always get you exactly what's inside the quotation marks--any charactersthat might otherwise have special meaning to the shell (like the dollar sign or the backslashare 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 $howdy
Good Morning hermie !

没有评论:

发表评论