BASH creating a file as part of a script

cat > newfile.txt <<'EOF'
contents of the new text file goes in here
it can span multiple lines

The above will create newfile.txt with 2 lines of content. If you quote the EOF, you can include special characters as part of the contents, otherwise you may end up with the error:

: bad substitution

Published: Wednesday, 21 January 2015