The construct you've found is called a "here document" and is described in the Bash manual under the heading "Here Documents" (followed by "Here Strings" that are related). It is a standard feature of any shell implementing the POSIX standard for shells. I believe that "here strings" is a Bash extension though.
It is good practice to do as in your example and use an upper-case string to mark the ending of the here document. Another good suggestions is to use XXX_END
(with XXX
being, e.g., XML
, DOC
, DATA
, SQL
or whatever it is you're feeding into the command) as the delimiter to further document the here document.
If the word used as a delimiter is quoted, the shell will not do parameter expansion (etc.) on the contents of the here document:
$ cat <<'TEST_END'
my $HOME is where I hang my hat
TEST_END
results in:
my $HOME is where I hang my hat
while
$ cat <<TEST_END
my $HOME is where I hang my hat
TEST_END
(on my laptop) results in
my /Users/kk is where I hang my hat