Here Docs
Explore the use of here documents and here strings in Bash to simplify multi-line text handling within scripts. Understand how to create and manipulate here docs, manage variable interpretation, and apply indentation for readability.
We'll cover the following...
Note: In this lesson, leading spaces are tabs. We have covered this in a previous lesson, but as a reminder: to get a tab character in your shell, type
\C-v, and then hit theTABbutton.
How Important is this Lesson?
Here documents, once learned, are used frequently in bash scripts or on the command line. It’s a piece of knowledge that separates the experienced user from the junior.
Basic Here Docs
Type this in to see the basic form of the here doc:
The first line starts with cat followed by a redirection to a file.
Then you use two left chevrons and follow that with a string that represents
a marker for the end of the file’s contents. In this case, the word is END.
Then you type in whatever you ...