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.
<command> << <EOF> <Enter> <multiline_text> <Enter> <EOF> <command> << <EOF> <Enter> <multiline_text> <Enter> <EOF> #!/bin/bash
# Here Document To Stdin
{{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
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
- Step 1
Enter the multiline block exactly as required by the command after the heredoc opener.
- 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.
$<VARIABLE> Secon / Get Security Context Process Linux secon --pid <1> Mlr / Sort Descending Numerically On Field mlr --icsv --opprint sort -nr <field> <example.csv> Secon / Get Security Context Current Execution Linux secon Nuclei / Run Templates With Custom Rate Limit nuclei -rl <150> -bs <25> -c <25> -silent -u {https://example.com}