What are here documents and here strings in bash?

Answer

A here document (heredoc) provides multi-line input to a command inline in a script. Syntax: command <. The delimiter (EOF) can be any word; the heredoc ends at a line containing exactly that word. Variables are expanded by default; use <<'EOF' to prevent expansion. <<-EOF strips leading tabs (not spaces). Example: ssh user@host <<'EOF'\nls -la\npwd\nEOF. A here string feeds a single string to a command's stdin: command <<< "string". Example: grep "pattern" <<< "$variable" or read a b c <<< "1 2 3". Heredocs are used for generating config files, SQL queries, and multi-line messages in scripts.