15.2. Double quotes
Use the double quotes to take literally everything except the following characters: $, ` , \. That’s a dollar, back quote and backslash; these characters keep their special meanings to the shell. If we assigned a string to a variable using double quotes to echo it, we see that there is no difference when echoing the variable.
$ STRING="MAY DAY, MAY DAY, GOING DOWN"
$ echo "$STRING"
MAY DAY, MAY DAY, GOING DOWN
$ echo $STRING
MAY DAY, MAY DAY, GOING DOWN
Now suppose we want to assign the system’s date output to a variable called mydate:
$ MYDATE="date"
$ echo $MYDATE
date
Because the shell is taking everything ‘as is’ inside the string, the date has no special significance, therefore will hold just the word date.
When ...
Get Linux and Unix Shell Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.