cat> 文件名<<eof
用來建立文件
在這以後輸入任何東西 都是在 文件裏的
輸入完成以後EOF結尾 表明結束
好比
cat > 1.txt <<eof
1
2
3
4
5
eof
就是建立1.txt這個文件裏面內容是 1 2 3 4 5
============================================
cat <<EOF與cat <<-EOF的區別(原文:http://blog.csdn.net/apache0554/article/details/45508631)
兩個都是獲取stdin,並在EOF處結束stdin,輸出stdout。apache
可是<<-是什麼意思呢?spa
先來看man中的說明:.net
If the redirection operator is <<-, then all leading tab characters are stripped from input lines and the line containing delimiter. 翻譯
翻譯過來的意思就是:若是重定向的操做符是<<-,那麼分界符(EOF)所在行的開頭部分的製表符(Tab)都將被去除。code
這能夠解決因爲腳本中的天然縮進產生的製表符。blog
通俗一點的解釋:ip
在咱們使用cat <<EOF時,咱們輸入完成後,須要在一個新的一行輸入EOF結束stdin的輸入。EOF必須頂行寫,前面不能用製表符或者空格。get
好比,下面的語句就不會出錯:input
- cat <<EOF
- Hello,world!
- EOF
而<<-就是爲了解決這一問題:
- cat <<-EOF
- Hello,world!
- EOF
這就是<<和<<-的區別。