Write Multi-Line Files With Here-Documents
Embed configuration or scripts inline using <<'EOF' blocks.
Use cat <<'EOF' > file ... EOF to write a literal multi-line block to a file.
01Command
Command
$ cat <<'EOF' > config.ini
[app]
name=cmdcv
EOF02What it does
A here-document feeds everything up to the delimiter as standard input, which keeps configuration or generated scripts readable inside a shell script. Quoting the delimiter disables variable expansion, so content is written literally. Editing many files by hand in a GUI does not scale like this does.
03Risk
!Warning: An indented delimiter will not close the block; use <<- only with tabs, or keep the delimiter at column zero.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- bash.1.en.html manual pageEvidence: The bash manual page documents here-documents.
Last verified: 2026-10-13 · Category: Developer