TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
<< operator, known as a Here-Document (or heredoc), is an I/O redirection mechanism in Bash. It instructs the shell to read a block of string literals from the current input stream and redirect it to the standard input (stdin) of a specified command. The shell continues reading until it encounters a predefined, user-specified delimiter token on a line by itself.
Parsing and Expansion Mechanics
By default, the shell parses the body of a Here-Document similarly to a double-quoted string. It subjects the content to three specific types of expansion before passing it to the command:- Parameter Expansion (
$VAR) - Command Substitution (
$(command)or`command`) - Arithmetic Expansion (
$((expression)))
$, `, or \), it must be escaped using a backslash (\).
Delimiter Quoting (Literal Mode)
If any character of the opening delimiter is quoted (using single quotes, double quotes, or a backslash), the shell alters its parsing behavior. It disables all expansions within the Here-Document body, treating the entire block as a raw, literal string.The <<- Variant (Tab Stripping)
Appending a hyphen to the operator (<<-) modifies the shell’s whitespace handling. When <<- is used, the shell strips all leading tab characters (\t) from every line within the Here-Document body, as well as from the line containing the closing delimiter.
This variant exists strictly for source code formatting, allowing the Here-Document to be indented to match the surrounding script structure without passing the indentation to the command’s stdin.
<<- operator strictly strips tab characters. Leading spaces are preserved and passed to the command.
Termination Constraints
The shell enforces strict lexical rules for the closing delimiter:- It must be the exact character sequence specified by the opening delimiter.
- It must reside on its own line.
- It cannot be preceded by any characters (except tabs if
<<-is used). - It cannot be followed by any characters, including trailing spaces, semicolons, or comments.
Master Bash with Deep Grasping Methodology!Learn More





