From: Kenn Humborg (kenn at domain linux.ie)
Date: Mon 15 May 2000 - 11:08:14 IST
On Mon, May 15, 2000 at 10:18:53AM +0100, Noel Carroll wrote:
> What the hell is
> a 'here' file and is there more to it than just an _EOF_ flag as was
> detailed in the article.
Imagine you want to send a multi-line mail message from a script:
#!/bin/sh
( echo This is a long message
echo and this is line 2
echo and this is line 3
echo don\'t forget to quote quotes
echo $USER will be substituted with username
) | mail -s "stupid message" kenn
You can also do this using here documents:
#!/bin/sh
mail -s "stupid message" kenn <<END_OF_MESSAGE
This is a long message
and this is line 2
and this is line 3
don't need to quote quotes
$USER will not be substituted
END_OF_MESSAGE
This lets you 'inline' a bunch of data. You end the data with a line
containing only the token that follows the << operator.
If you want to make the content of the here document easier to
see, you can indent them with tabs and use <<- instead of <<.
Bash will remove the leading tabs.
Later,
Kenn
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:08 GMT