Skip to content
The Bash Insectarium

/static/insetario/en/inseto/heredoc/

Menu

BSH-017 · Documents

<<

The text enters the command right there, up to the agreed word.

The here-document feeds the command's input with the lines that follow, up to the line holding only the delimiter. With the delimiter bare, variables and commands expand inside; quoted — << 'END' — the text crosses literal.

The <<- variant strips tabs from the start of each line: the block can follow a script's indentation without carrying it into the text. Tabs only — spaces stay.

$ cat << FIM > bilhete.txt
> ao entrar no formigueiro,
> limpe as antenas.
> FIM
$ cat bilhete.txt
ao entrar no formigueiro,
limpe as antenas.
Two lines delivered with no editor and no echo.