Bash 5 reference · Shell Builtins and Syntax
here-document (Bash syntax)
Feed multiple lines to a command with <<EOF; quote the marker to stop variable expansion, use <<- to strip tabs.
Bash 5
Syntax
cmd <<EOF ... EOF cmd <<'EOF' ... EOF cmd <<< 'string'
Parameters
| Parameter | Description |
|---|---|
<<EOF |
Variables and $(...) are expanded. |
<<'EOF' |
Literal: nothing expanded. |
<<< |
Here-string: one string as input. |
Examples
name=api
cat <<EOF
service: $name
literal: \$name
EOF
Output
service: api literal: $name
Run this on your computer — see “Get Started” for setup.
cat <<'EOF' > script.sh
echo "$HOME stays literal"
EOF
cat script.sh
tr a-z A-Z <<< 'here-string'
Output
echo "$HOME stays literal" HERE-STRING
Run this on your computer — see “Get Started” for setup.
Related
redirection· Send output to files, read input from files, merge stderr into stdout, and discard output with /dev/null.printf· Print formatted text with format specifiers like %s, %d and %.2f; more portable and predictable than echo.- Bash Here Documents and printf · tutorial