Cat (difference between EOF and cat (-EOF)

Source: Internet
Author: User

Cat (difference between EOF and cat (-EOF)

Both get stdin, end stdin at EOF, and output stdout.

But <-what does it mean?

Let's take a look at man's description:

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

If the redirection operator is <-, the tabs at the beginning of the line where the delimiter (EOF) is located will be removed.

This can solve the tabs generated by natural indentation in the script.

A more general explanation:

When we use cat <EOF, We need to input EOF in a new row to end the stdin input. The EOF must be written in the top line, and no tabs or spaces can be used in front of it.

For example, the following statement will not make an error:

Cat <EOFHello, world! EOF
If there is a tab or space before the end separator EOF, The EOF will not be treated as the end separator, but will continue to be input as stdin. <-To solve this problem:
Cat <-EOFHello, world! EOF
In the preceding statement, although there are multiple tabs and spaces in front of the last EOF, it is still treated as an end separator, indicating the end of stdin. This is the difference between <and <.



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.