Where do people use the "Here document" on UNIX systems?
Where is it used in reality?
ftp and the like are good examples.
For instance, if you want to stablish an ftp connection and retrieve some files you can create a script that does something like:
#!/bin/bash
lftp machine -uUser,Passwd << END
cd your_dir
get your_file
bye
END
You have automated files retrieval with a "Here document"
It is often used for multi line output.
Compare
echo "first line" >output
echo "second line" >>output
echo "third line" >>output
and
cat >output <<"END"
first line
second line
third line
END
Both should do exactly the same, but especially with long text the second version is easier.
A here document is a special-purpose code block. It uses a form of I/O redirection to feed a command list to an interactive program or a command, such as ftp, cat, or the ex text editor.
A more detailed example and explanation can be found here:
A grep
command example for "Here document":
grep this <<"END"
> this is an example
> with example
> END
this is an example