Write to File
Append
cat << EOF >> /tmp/myfile.txt
Contents that are added to the file at the end
You can indent files by spacing them appropriately
EOF
Noteworthy
- Make sure the last
EOF
(called theLimitString
) is actually the very first item on the line. Do not indent, do not do anything other than makeEOF
begin at position #1. If you wish to indent yourLimitString
, you can use<<-
to disable leading tabs. - If you do not want to interpret variables in the text, use single quotes around the first
LimitString
:cat << 'EOF' > /tmp/myfile.txt
- To write the heredoc to a file using
sudo
:cat << 'EOF' | sudo tee /etc/http.d/my_ssl_config