Literals/String: Difference between revisions

Notes on shell quotation marks from markhobley.yi.org
No edit summary
(Notes on shell quotation marks from markhobley.yi.org)
Line 945:
 
Double quotes enclose strings, e.g. <code>"Hello Rosetta Code"</code>. There are no escape characters. Quotes in strings are doubled: <code>"This > "" < is one double-quote."</code>
=={{header|UNIX Shell}}==
 
{{works with|Bourne Shell}} {{works with|bash}}
 
The Unix shell supports several types of quotation marks:
 
* singlequotes - for literal string quotation
* doublequotes - for interpolated string quotation
* backticks - Used to capture the output from an external program
 
=== Quotation marks within a literal String ===
 
It is possible to place singlequote characters within a string enclosed with doublequotes and to put doublequote characters in a string enclosed within singlequotes:
<lang sh>
echo "The boy said 'hello'."
echo 'The girl said "hello" too.'
</lang>
 
We can also use an escapesequence to put doublequote characters in an interpolated string:
 
<lang sh>
print "The man said \"hello\".";
</lang>
 
=== Here documents ===
 
The shell supports the use of here documents for the inclusion of quoted text:
<lang sh>
$address = <<END;
1, High Street,
SMALLTOWN,
West Midlands.
WM4 5HD.
END
</lang>
 
=={{header|Ursala}}==