1. Glossary:
The following is Wikipedia's explanation:
Here document[1], also known as heredoc, hereis, here-string or here-script, is a shell (such as SH, CSH, KSh, Bash, powershell, and zsh) in the command line) and define a string method in the program language. It can save the line breaks, dashes, and other blank characters in the text. Some languages allow variable replacement and command replacement in strings.
The most common syntax of the here document is<<Keep up with an identifier, starting from the next line is the text to be referenced, and then close it with the same identifier on a separate line. In Unix shell, the here document is usually used to provide input content for commands.
It seems complicated. The purpose of the here document is to deliver a series of commands that need to be input from the keyboard, simulating manual input, one line at a time to interactive applications or commands.
The format is:
$ tr a-z A-Z <<END_TEXT > one two three > uno dos tres > END_TEXT ONE TWO THREE UNO DOS TRES
END_TEXTUsed as an identifier. It specifies the start and end of the here document,ONE
TWO THREEAndUNO DOS TRESYes after executiontr.
2. Example
$ cat << EOF > Working dir $PWD > EOF Working dir /home/user
EOF calibrated the start and end of here. This example is equivalent to the input of cat working dir $ PWD, and the output is the same. Do you understand?
Dir $ PWD) is the input of the command (CAT) before the here document!
Note: The here document requires that the input data, especially the string separator "limitstring" used as the end mark, be located at the starting position of a separate line.