EOF in shell scripts and file redirection

Source: Internet
Author: User

<<eof
Content
EOF

You can replace EOF with something else (the decomposition character)
It means to pass the content as standard input to the program.

Here is a brief look at the use of <<. When the shell sees <<, it will know that the next word is a demarcation
Character. The content after the delimiter is treated as input until the shell sees the delimiter again (on a separate line). This one
The delimiter can be any string that you define.

Frequently used file redirection:

Command > FileName redirect standard output to a new file
Command >> filename REDIRECT standard output to a file (append)
Command 1 > FileName REDIRECT standard output to a file
Command > FileName 2 >&1 redirect standard output and standard error to a file
Command 2 >filename redirect the standard error to a file
Command 2 >> filename redirects a standard error to a file (append)
Command >> filename 2 >&1 redirect standard output and standard error to a file (append)
The command < filename > filename2 command commands the filename file as the standard input,
filename2 file as standard output
Command < filename commands with filename file as standard input
Command << delimiter is read from the standard output until the delimiter delimiter is encountered
Command <&m the file descriptor m as standard output
Command >&m redirect the standard output to the file descriptor m
Command <&-to turn off standard input

Note: <<delimiter as the delimiter is absolutely not mixed with <<filename, because the latter does not exist at all ...

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.