O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required