You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/heredocs/about.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ DELIMITER
28
28
## How it Works
29
29
30
30
* Bash reads all the lines between the starting `<< DELIMITER` and the ending `DELIMITER`.
31
-
*This content is then treated as standard input (`stdin`) to the command.
31
+
*Bash connects this content to the command's standard input.
32
32
* The command processes this input as if it were coming from the keyboard.
33
33
34
34
### Example 1: Simple Text Output
@@ -130,7 +130,7 @@ The current date is Thu Apr 24 13:47:32 EDT 2025
130
130
Two plus two is 4
131
131
```
132
132
133
-
Quoting the delimiter (single or double quotes) prevents these expansions.
133
+
When the delimiter is quoting (using single or double quotes), these expansions are prevented.
134
134
The content is taken literally.
135
135
This is like single quoted strings.
136
136
@@ -157,10 +157,11 @@ This is useful for indenting the heredoc content within your script without affe
157
157
158
158
```bash
159
159
# Note, the leading whitespace is tab characters only, not spaces!
160
+
# and the ending delimiter can have leading tabs as well
160
161
cat <<- END
161
-
This line has a leading tab.
162
-
This line also has a leading tab.
163
-
END
162
+
This line has a leading tab.
163
+
This line also has a leading tab.
164
+
END
164
165
```
165
166
166
167
The output is printed without the leading tabs:
@@ -171,7 +172,7 @@ This line also has a leading tab.
171
172
```
172
173
173
174
The author doesn't recommend this usage.
174
-
While it does improve the readability of the script, it's too easy to accidentally replace the tab characters with spaces and it's too hard to spot the difference.
175
+
While it can improve the readability of the script, it's too easy to accidentally replace the tab characters with spaces and it's too hard to spot the difference.
0 commit comments