Shell Programming--eof

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.