here document

A way to write several lines of text straight into a script or file, opened with << and a marker word such as EOF and closed by that word on its own line.

In more detail

In a shell, the text becomes the command's standard input, and variables inside are expanded unless the marker is quoted, as in << 'EOF'. The <<- form lets the text be indented: shells strip leading tabs, and HCL strips the common leading indentation. The name comes from shells, where the text is fed to a command from right here in the script.

Examples

cat << EOF
Dear $name,
Your report is ready.
EOF
docker exec -i broker sh -c 'cat > /tmp/v1.json' << 'EOF'
script = <<-EOT
  line one
  line two
EOT

Related terms

Taught in

References

Certification courses