LDP/LDP/guide/docbook/abs-guide/ex71c.sh

42 lines
783 B
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2006-12-20 21:11:55 +00:00
# A 'cat' here-document, but with parameter substitution disabled.
2001-07-10 14:25:50 +00:00
NAME="John Doe"
RESPONDENT="the author of this fine script"
cat <<'Endofmessage'
Hello, there, $NAME.
Greetings to you, $NAME, from $RESPONDENT.
Endofmessage
2006-12-20 21:11:55 +00:00
# No parameter substitution when the "limit string" is quoted or escaped.
# Either of the following at the head of the here document would have
2007-04-26 21:13:49 +00:00
#+ the same effect.
2006-12-20 21:11:55 +00:00
# cat <<"Endofmessage"
# cat <<\Endofmessage
2001-07-10 14:25:50 +00:00
2009-09-29 15:08:03 +00:00
# And, likewise:
cat <<"SpecialCharTest"
Directory listing would follow
if limit string were not quoted.
`ls -l`
Arithmetic expansion would take place
if limit string were not quoted.
$((5 + 3))
A a single backslash would echo
if limit string were not quoted.
\\
SpecialCharTest
2008-11-23 22:43:47 +00:00
exit