Besides of opening a file using vim and emacs, there is another single way to write some characters into one file.
Here (aka here-document, here-text, heredoc, hereis, here-string or here-script) is a file literal or input stream literal: it is a section of a source code file that is treated as if it were a separate file. The term is also used for a form of multiline string literals that use similar syntax, preserving line breaks and other whitespace (including indentation) in the text.
Here are some sample:
Basically, you can write as follow
$ cat << delimiting_identifier ... your text here ... your text here another line ... delimiting_identifier your text here your text here another line
you can replace "cat" using tr, read or something else, you can also replace delimiting_identifier using other word.
By default, behavior is largely identical to the contents of double quotes: variables are interpolated, commands in backticks are evaluated, etc.
$ cat << delimiting_identifier ... $(whoami) ... delimiting_identifier yu
To prevent this replacement, we can write as follow:
$ cat << 'delimiting_identifier' ... $(whoami) ... delimiting_identifier $(whoami)
It is a very important feature for us.
We can easily generate some fies in script, and write multiline lines to this file.
xqiushi · June 8, 2017 at 18:04