Check this two examples of here document in BASH.
First one, classic:
$ cat >file-sh<<EOF string="hello world" echo $string EOF
Second one, new magic I learnt today:
$ cat >file2-sh<<"EOF" string="hello world" echo $string EOF
There’s a big difference:
$ diff file-sh file2-sh 2c2 < echo --- > echo $string
First notice, and it saved my day!
Update: if you’re reading this post through your feed reader, the examples may look weird. Blame Tumblr: the way they generate the RSS it’s broken.
