In shell programming, "EOF" is often used in conjunction with "<<",
"<<eof" indicates that subsequent input is entered as a subcommand or child shell until "EOF" is encountered and returned to the keynote shell again.
It can be interpreted as a delimiter (delimiter). Since it is a delimiter, the form is naturally not fixed, where "EOF" can be customized, but the front and back "EOF" must appear in pairs and cannot conflict with shell commands. It is used in the following form:
Interactive Program (command) <<eofcommand1command2 ... Eof |
The content in the middle of "EOF" will be entered as a standard input to the "interactive program", when the shell sees "<<" knows the delimiter entered after it, and when the shell sees the delimiter again, the middle portion of the two delimiter is used as the standard input. "EOF" is commonly used with cat commands. Note that the final "EOF" must be a separate line. The following is an example of "EOF" used with the cat command. Generally there are two forms of the1.cat<<eof2.cat<<eof>filename or Cat<<eof>>filename( cat<<eof>filename or Cat<<eof>>filename ) In fact, there is no essential difference between the first form and the second form, the first form outputs the content directly to the standard output (screen), while the second form redirects the standard output and redirects the content that should be output to the screen to the file. Example 1:#cat <<eof>12>34d>eof A34D Example 2:#cat >>filename<<eof>dha>23>eof#cat filenameDHA at
Shell Programming--eof