Here Document
Syntax:
command << label
input line 1
…
input line n
label
This allows you to redirect input to a shell script from within the shell script itself.
- << label indicates that label marks the end of the here document
- label must appear on a line by itself to end the here document
- << 'label' prevents the shell from doing parameter and command substitution in the here document
- <<- label deletes leading tabs (but not spaces) from the here document
Here Document Example
(from page 189 in "Learning the Korn Shell")
pgmname=$1
for user in $(ypcat passwd | cut -f1 -d:)
do
mail $user <<- EOF
Dear user,
A new version of $pgmname has been installed
in $(whence $pgmname).
Regards,
Your friendly sysadmin
EOF
done
原文: http://snap.nlc.dcccd.edu/reference/scarlatos/cis2.50/note6.html