| Start |
|---|
Execute command with here document
Another way: Note: The closing EOF should be at the beginning of the line (No whitespaces before). If indentation is required, tabs may be used if you start your heredoc with |
| Indenting here documents You can indent the text inside here documents with tabs, you need to use the One practical use case of this (as mentioned in It is customary to indent the lines within code blocks as in this That's very unpleasant to read, and it gets much worse in a more complex realistic script. |
| Here documents and here strings |
| Create a file A classic use of here documents is to create a file by typing its content: The here-document is the lines between the This here document becomes the input of the As a result, the The usual rules of output redirection apply:
if |
Run several commands with sudo
Or |
| Limit Strings A heredoc uses the limitstring to determine when to stop consuming input. The terminating limitstring must
Correct: This will output: Incorrect use: Since Note that when you prefix the initial limitstring with a hyphen, any tabs at the start of the line are removed before parsing, so the data and the limit string can be indented with tabs (for ease of reading in shell scripts). will produce with the leading tabs (but not the internal tabs) removed. |
Read Article
https://develop.horje.com/learn/1434/reference