BASH creating a file as part of a script

Published: Wednesday, 21 January 2015
cat > newfile.txt <<'EOF'
contents of the new text file goes in here
it can span multiple lines
EOF

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