Here Docs

Here docs for creating blocks of text

Here Docs

1
2
3
cat << EOF > output_file.txt
 content of file
EOF
  • Little things you learn: the EOF (or equivalent) on a here-document in bash needs to be at the start of a line, and not indented at all.
  • Little things you also learn about heredocs: if you leave the heredoc keyword (i.e. EOF) unquoted then the heredoc body is processed locally, so that $FOO is expanded; quote your EOF and you are left with $FOO unexpanded.