here document operator
is used in shell scripts.
It tells the shell to take lines from the script as standard input to a command.
The example below shows
a loop (45.17)
that prints three nasty form letters with the
Each letter has a different person's name and the current date at the top.
You can put this loop into a
shell script (44.2)
or just type it in
at a Bourne shell prompt (9.12, 9.13).
Each line of the loop body starts with a TAB character, which the
<<- operator removes before the printer gets the text:
for person in "Mary Smith" "Doug Jones" "Alison Eddy" do lpr <<- ENDMSG `date` Dear $person, This is your last notice. Buy me pizza tonight or else I'll type "rm -r *" when you're not looking. This is not a joak. Signed, The midnight skulker ENDMSG done
This loop runs three lpr commands; each form letter prints on a
The shell reads the standard input until it finds the
terminator word, which in this case is |