cat使用时碰到的一个坑

[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会将引用的命令执行后再保存。

猜你喜欢

转载自www.cnblogs.com/viewshadow/p/9284585.html