Language - Here Document in Bash.
Here document in Bash is implemented through redirection. A redirection instructs the shell to read input from the current source until a line containing only word (with no trailing blanks) is seen. All of the lines read up to that point are then used as the standard input for a command.
foo="foo"
cat <<-HereDoc
my Variable is $foo
HereDoc
my Variable is foo
foo="foo"
cat <<-"HereDoc"
my Variable is $foo
HereDoc
my Variable is $foo
read -r -d '' MY_VARIABLE << 'EOF'
Content
With
Multiple Line
EOF
MY_VARIABLE=$(cat << 'EOF'
Content
With
Multiple Line
EOF
)
Note that you can also create a multiline value with just the quote syntax
MY_VARIABLE="Line 1
Line 2
Indented line
Line with \$variables and \"quotes\""
The format of here-documents is:
<<[-]wordDelimiter
here-document
wordDelimiter
where:
Bash variant: The word is expanded and supplied to the command on its standard input.
<<< word
No:
is performed on the first WordDelimiter.
If the first wordDelimiter is:
In the latter case, the character sequence \<newline> is ignored, and \ must be used to quote the characters \, $, and ‘.
The second WorldDelimiter is generally the result of quote removal on the first WordDelimiter.