[root@gr ~]# cat<<EOF>/script/tar_hours.sh
> #!/bin/bash
> tar cvf /tmp/services-`date +%F_%H`.tar /etc/services
> EOF
[root@gr ~]# cat /script/tar_hours.sh
#!/bin/bash
tar cvf /tmp/services-2018-07-09_16.tar /etc/services
使用cat保存内容时,cat会将引用的命令执行后再保存。