whatis heredoc

Heredoc

Also known as: here document, <<EOF

Shell syntax (<<EOF ... EOF) that feeds a multi-line block of text into a command's standard input.

What Is a Heredoc in Bash?

A heredoc is the cleanest way to write a config file or pass a multi-line SQL query from a script. Everything between the opening <<MARKER and a line containing only MARKER becomes stdin.

Variables are expanded inside a heredoc unless you quote the marker (<<'EOF'). Using <<- strips leading tabs so you can indent the block inside functions.

Example

cat <<'EOF' > /etc/motd
Authorized use only.
EOF