{
     echo line1
     echo line2
     echo line3
     ...etc...
   } >file

�Here documents� in bash are also useful for this kind of work. In many ways, they�re better, because they preserve the formatting of the document completely:

#!/bin/bash
foo=�Some Variable"
cat > file << EOF
verbatim text here
   more verbatim text here, with preceding whitespace preserved
no echo command needed
expand some variable here: $foo
EOF

will produce a file that contains everything between the two EOFs exactly. It will still expand the contents of $foo out appropriately

$ ./heredoctest.sh 
$ cat ./file 
verbatim text here
   more verbatim text here, with preceding whitespace preserved
no echo command needed
expand some variable here: Some Variable

More on heredocs here: http://wiki.wlug.org.nz/HereDocuments