cat> file name <<eof
Used to create a file
After that, everything was entered in the file.
After the input is complete, the EOF end represents the end
Like what
Cat > 1.txt <<eof
1
2
3
4
5
Eof
is to create 1.txt this file contains 1 2 3 4 5
============================================
The difference between cat <<eof and Cat <<-eof (original: http://blog.csdn.net/apache0554/article/details/45508631)
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 be stripped from input lines and T He 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 <<eof
- hello,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 <<-eof
- hello,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 <<-.
How to use cat > File << EOF