command Verified current stable Not installed?

Command / Here Document To Stdin

Here Document To Stdin

During configuration scripts that require multiline parameters. Exact Command syntax, copyable example, output expectations, and common mistakes.

$
Terminal
<command> << <EOF> <Enter> <multiline_text> <Enter> <EOF>

When To Use

Use this when inline multiline shell input is clearer than creating a separate file first.

Pro Tip

Keep the heredoc terminator on its own line so the shell closes the block where you expect.

Command Result

What happens when it runs

Shell behavior

Primary Effect

Uses shell redirection. The shell provides input from the source file before Command runs.

Terminal Expectation

The shell may not print a visible result. Validate the affected input or output path after the command runs.

Troubleshooting

Common pitfalls

The heredoc terminator does not match

Solution: Use the same marker at both the start and end of the heredoc block.

Indentation changes the heredoc content

Solution: Check whether the command uses << or <<- before indenting lines.

Command Breakdown

What each part is doing

<command>
Base Command
The executable that performs this operation. Here it runs Command before the shell applies any redirect operators.
<command>
command
The value supplied for command.
<multiline_text>
multiline text
The value supplied for multiline text.
<<
Shell Redirection
Changes how the shell routes input or output for this command.
<EOF>
Input Source
The file or token that provides shell input for this command.

How To Run

Execution path

  1. Step 1

    Enter the multiline block exactly as required by the command after the heredoc opener.

  2. Step 2

    Terminate the heredoc with EOF and then verify the resulting file or stdout.

Alternative Approaches

Comparable commands in other tools

Alternative tools that share the "process-text" operation intent.