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 <.