Linux's eof is a custom terminator, its full name is "END Of File"; eof is not fixed, you can set an alias at will, press "ctrl-d" in Linux to represent eof; eof generally With cat, multiple lines of text can be output.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
What does eof in Linux mean?
How to use EOF in shell basics
EOF is the abbreviation of (END Of File), which represents a custom terminator. Since it is customized, EOF is not fixed. You can set the alias at will. Press ctrl-d in linux to represent EOF.
EOF usually works with cat to output multi-line text.
## Its usage is as follows:
##<
#End You can also customize, for example:
<
ABC
#End
Using cat with redirection, you can generate files and append operations. Before doing it, be familiar with a few special symbols
##< : Input redirection
>: Output redirection
##>>: Output redirection, will be appended, will not overwrite the previous content
##< ;<
: Standard input comes from the middle of a pair of delimiters on the command line## Example
1:##[root@ren5 ~]# cat <
> EOFhello
We know that the operation object of cat is a file, but in example 1, the operation object of cat is not a file, but a user Input; then we can understand example 1 like this: first enter "Hello" in the file file, and then use cat file to output it Content.
That is to say, we can use a file to replace "<< EOF EOF".
On the other hand, if the file in the operation command is the input object, you can also use "<< EOF EOF" Replacement.
Example2:
[root@ren5 ~]# cat 1.txt
abc
[root@ren5 ~]# cat <
> 456
> 678
##> LOL
> EOF
[root@ren5 ~]# cat 1.txt
123
456
678
LOL
"
<< EOF EOF" is used for user-defined input during command execution. It is similar to the role of a temporary file, but is smaller than Using files is more convenient and flexible. 2. The difference between cat <
stdin, and ends stdin at EOF, and outputs stdout. ##When we use
cat <<<-, then the delimiter ( EOF) Tab characters (Tab) at the beginning of the line will be removed. This resolves tabs caused by natural indentation in scripts.
Example1:[root@ren5 ~]# cat 2.sh
#!/bin/bash
##cat <
##Hello, EOF! ##EOF
[root@ren5 ~]# sh 2.sh
Hello,
EOF! [root@ren5 ~]# sh 2.sh
##2.sh:line
4 :Warning:Immediate document at line 2 is delimited by end-of-file (requires `EOF') Hello,
EOF! ## EOF
If there is a tab or space before the end decomposition character EOF
, ThenEOF will not be regarded as the end delimiter, and will only continue to be entered as stdin. Example
2: [root@ren5 ~]# cat 2.sh
#!/bin/bash
cat << -EOF
Hello, EOF
!## EOF
[root@ren5 ~]# sh 2.sh##Hello,
EOF!
Although the final EOF is preceded by multiple tabs and spaces, it will still be regarded as the end delimiter, indicating ## The end of #stdin.
Recommended study: "linux video tutorial"
The above is the detailed content of What does eof in linux mean?. For more information, please follow other related articles on the PHP Chinese website!