EOF是END Of File的缩写,表示自定义终止符。
既然自定义,那么EOF就不是固定的,可以随意设置别名。
在linux按ctrl-d就代表EOF。
EOF一般会配合cat能够多行文本输出.
其用法如下:
<<EOF //开始
....
EOF //结束
还可以自定义,比如自定义:
<<BBB //开始
....
BBB //结束
样例:
[root@localhost test]# cat << EOF > test.sh
> 123456789
> abcdefghj
> tdss32323
> EOF
[root@localhost test]# cat test.sh
123456789
abcdefghj
tdss32323
[root@localhost test]# cat << BBB > test.sh
> dddddddddd
> aaaaaaaaaa
> eeead12133
> BBB
[root@localhost test]# cat test.sh
dddddddddd
aaaaaaaaaa
eeead12133
如果想追加 cat << EOF >> test.sh
更多推荐
Linux中命令行中EOF的用法
发布评论