Here-document
The redirection operators << and <<- both allow redirection of lines contained in a shell input file, known as a here-document, to the standard input of a command.
The here-document is treated as a single word that begins after the next newline character and continues until there is a line containing only the delimiter, with no trailing blank characters. Then the next here-document starts, if there is one. The format is as follows:
[n]<<word
here-document
delimiter
If any character in word is quoted, the delimiter is formed by performing quote removal on word, and the here-document lines will not be expanded. Otherwise, the delimiter is the word itself.
If no characters in word are quoted, all lines of the here-document will be expanded for parameter expansion, command substitution and arithmetic expansion. In this case, the backslash in the input will behave as the backslash inside double-quotes (see Double-quotes ). However, the double-quote character (") will not be treated specially within a here-document, except when the double-quote appears within $( ), ` ` or ${ }.
If the redirection symbol is <<-, all leading tab characters will be stripped from input lines and the line containing the trailing delimiter. If more than one << or <<- operator is specified on a line, the here-document associated with the first operator will be supplied first by the application and will be read first by the shell. For example:
cat <<eof1; cat <<eof2
Hi,
eof1
Helene.
eof2
The case of a missing delimiter at the end of a here-document is not specified. This is considered an error in the script (one that sometimes can be difficult to diagnose), although some systems have treated end-of-file as an implicit delimiter.
The redirection operators << and <<- both allow redirection of lines contained in a shell input file, known as a here-document, to the standard input of a command.
The here-document is treated as a single word that begins after the next newline character and continues until there is a line containing only the delimiter, with no trailing blank characters. Then the next here-document starts, if there is one. The format is as follows:
[n]<<word
here-document
delimiter
If any character in word is quoted, the delimiter is formed by performing quote removal on word, and the here-document lines will not be expanded. Otherwise, the delimiter is the word itself.
If no characters in word are quoted, all lines of the here-document will be expanded for parameter expansion, command substitution and arithmetic expansion. In this case, the backslash in the input will behave as the backslash inside double-quotes (see Double-quotes ). However, the double-quote character (") will not be treated specially within a here-document, except when the double-quote appears within $( ), ` ` or ${ }.
If the redirection symbol is <<-, all leading tab characters will be stripped from input lines and the line containing the trailing delimiter. If more than one << or <<- operator is specified on a line, the here-document associated with the first operator will be supplied first by the application and will be read first by the shell. For example:
cat <<eof1; cat <<eof2
Hi,
eof1
Helene.
eof2
The case of a missing delimiter at the end of a here-document is not specified. This is considered an error in the script (one that sometimes can be difficult to diagnose), although some systems have treated end-of-file as an implicit delimiter.