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
本文详细解释了HereDocument的概念、语法及其在KornShell中的应用,包括如何通过Heredoc将输入重定向到shell脚本内部,以及其在实际场景中的示例。
1940

被折叠的 条评论
为什么被折叠?



