Title here
Summary here
Using the -e
option can create simple multi-line text.
Here Document (abbreviated as Heredoc) is a way of input redirection in Shell, allowing you to embed multi-line text within scripts or commands and pass it to commands or files.
command
:such as cat
, sed
, gawk
.<<EOF
:marks the beginning of the document and defines the end marker.EOF
:marks the end position of the document.Here, EOF
is just an example, and any marker can be used.
Multi-line text can be redirected to the foo.txt
file.
If the EOF marker is used with quotes, the function will be different.
Quote Type | Variable/Special Character |
---|---|
EOF | Interpret |
'EOF' | Do Not Interpret |
"EOF" | Do Not Interpret |
If the content is just a pure document, try to use quotes to reduce the impact of special characters.
Single/double quotes are the same, and neither will interpret the $
symbol.
And not using quotes is the same, and will interpret the $
symbol.