< Day Day Up > |
Quotes are used to protect special metacharacters from interpretation. They can cause major debugging hassles in all shell scripts. Single quotes must be matched. They protect special metacharacters from being interpreted by the shell. Double quotes also must be matched. They protect most characters from interpretation by the shell, but allow variable and command substitution characters to be processed . Single quotes will protect double quotes, and double quotes will protect single quotes. The Korn shell, unlike the Bourne shell, will inform you if you have mismatched quotes by sending an error message to standard error with the line where it detects that the quotes were mismatched. 11.10.1 The BackslashThe backslash is used to protect (or escape) a single character from interpretation. Example 11.54.1 $ print Where are you going\? Where are you going? 2 $ print Start on this line and \ > go to the next line. Start on this line and go to the next line. EXPLANATION
11.10.2 Single QuotesSingle quotes must be matched. They protect all metacharacters from interpretation. To print a single quote, it must be enclosed in double quotes or escaped with a backslash. Example 11.55.1 $ print 'hi there > how are you? > When will this end? > When the quote is matched > oh' hi there how are you? When will this end? When the quote is matched oh 2 $ print 'Do you need .00?' Do you need .00? 3 $ print 'Mother yelled, "Time to eat!"' Mother yelled, "Time to eat!" EXPLANATION
11.10.3 Double QuotesDouble quotes must be matched. They allow variable and command substitution, and protect any other special metacharacters from being interpreted by the shell. Example 11.56.1 $ name=Jody 2 $ print "Hi $name, I'm glad to meet you!" Hi Jody, I'm glad to meet you! 3 $ print "Hey $name, the time is `date`" Hey Jody, the time is Fri Dec 18 14:04:11 PST 2004 EXPLANATION
|
< Day Day Up > |