1、有时候写脚本,需要写一些注释信息或者备注之类,当每次都手写比较麻烦,可以写一个脚本,每次运行则自动写入这些信息,不需要在手动输入;
通过 EOF 嵌入文档的方式;
[root@localhost_002 shell100]# cat add_title.sh
#!/bin/bash
d=`date +%F`
cat >$1<<EOF
#!/bin/bash
#这个脚本用来
#日期: $d
#作者: yuanhh
EOF
执行脚本: sh add_title.sh 66.sh
[root@localhost_002 shell100]# sh add_title.sh 66.sh
[root@localhost_002 shell100]# cat 66.sh
#!/bin/bash
#这个脚本用来
#日期: 2019-01-21
#作者: yuanhh