To Create a NEW FILE:
Note: Without quotes around EOL it will expand variables vs put them in script!.
cat << 'EOL' >/tmp/filename echo "this will be the first and only line in /tmp/filename" EOL
var="this will be the first and only line in /tmp/filename" cat << EOL >/tmp/filename echo $VAR EOL
To Append:
Same thing, but << EOL >> or << 'EOL' >>