In bash I can create a script with a here-doc like so as per this site: http://tldp.org/LDP/abs/html/abs-guide.html#GENERATESCRIPT
( cat <<\'EOF\' #!/bin
Non of the answers expanded environment variables. My workaround is a tmp file and a sudo mv.
l_log=/var/log/server/server.log l_logrotateconf=/etc/logrotate.d/server tmp=/tmp/$$.eof cat << EOF > $tmp $l_log { rotate 12 monthly compress missingok notifempty } EOF sudo mv $tmp $logrotateconf