Skip to content
The Bash Insectarium

/static/insetario/en/inseto/herestring/

Menu

BSH-018 · Documents

<<<

One word becomes the command's whole input: the pocket heredoc.

The here-string delivers the word — expanded, with a newline at the end — as the command's standard input. It is the heredoc reduced to one line.

The hidden gain shows up with read: in echo x | read var, the read runs in a subshell and the variable evaporates; with read var <<< x, it survives, because there is no pipe and no subshell.

$ read -r genero especie <<< "Apis mellifera"
$ echo "$genero / $especie"
Apis / mellifera
The phrase split into variables that stay alive.