EOF是(END Of File)的縮寫,表示自定義終止符。既然自定義,那么EOF就不是固定的,可以隨意設置別名,在linux按ctrl-d 就代表EOF。
EOF一般會配合cat能夠多行文本輸出。
其用法如下:
<<EOF #開始
.... #輸入內容
EOF #結束
還可以自定義,比如自定義:
<<ABC #開始
....
ABC #結束
例如,向test.txt文件輸入內容:
cat << EOF > test.txt > hello > world > EOF #或者,這樣寫達到同樣效果: cat > test.txt << EOF > hello > world > EOF
顯示test.txt文件內容:
root@ubuntu6:/home/lyh# cat << EOF test.txt > EOF hello world