EOF是END Of File的縮寫,表示自定義終止符。
既然自定義,那麼EOF就不是固定的,可以随意設定别名。
在linux按ctrl-d就代表EOF。
EOF一般會配合cat能夠多行文本輸出.
其用法如下:
<<EOF //開始
....
EOF //結束
還可以自定義,比如自定義:
<<BBB //開始
....
BBB //結束
樣例
[[email protected] test]# cat << EOF > test.sh
> 123456789
> abcdefghj
> tdss32323
> EOF
[[email protected] test]# cat test.sh
123456789
abcdefghj
tdss32323
[[email protected] test]# cat << BBB > test.sh
> dddddddddd
> aaaaaaaaaa
> eeead12133
> BBB
[[email protected] test]# cat test.sh
dddddddddd
aaaaaaaaaa
eeead12133
如果想追加 cat << EOF >> test.sh