The difference between cat <<eof and cat <<-eof

Source: Internet
Author: User

All two are get stdin, and end stdin at EOF, output stdout.

But what does <<-mean?

First look at the instructions in man:

If The redirection operator is <<- , then all leading tab characters is stripped from input lines and the line containing delimiter   .

If the redirected operator is <<-, then the tab (tab) will be removed from the beginning of the line where the delimiter (EOF) is located.

this resolves the tabs that are produced by natural indentation in the script.

A little more popular explanation:

When we use cat <<eof, we need to enter the EOF end stdin input on a new line when we are done entering. EOF must be written in the top row and cannot be preceded by tabs or spaces.

For example, the following statement does not go wrong:

Cat <<eofhello,world! Eof
If there are tabs or spaces before the end-of-break EOF, EOF is not treated as an end-delimiter and will only continue to be entered as stdin. and <<-is to solve this problem:
Cat <<-eofhello,world!      Eof
the above notation, although there are several tabs and spaces in front of the final EOF, will still be treated as an end delimiter, indicating the end of the stdin. This is the difference between << and <<-.



The difference between cat <<eof and cat <<-eof

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.