这里讲的是多重嵌套。没用过 EOF的朋友请参考其他基础贴

在自动化运维中,常常需要shell脚本。在自动化创建脚本时,会遇到脚本内容里有用EOF重定向到配置文件的代码。

这样就不能用EOF来创建脚本了,所以要多方法混用来实现自动化。

重定向方法1:

cat > /tmp/.txt << EOF
This is line of the message.
This is line of the message.
This is line of the message.
This is line of the message.
This is the last line of the message. EOF

重定向方法2:参考https://linux.die.net/abs-guide/here-docs.html,有更多高级用法,纯英文网站,我目前双层嵌套就够用了。所以没多看。

cat > /tmp/.txt << ENDOFMESSAGE
This is line of the message.
This is line of the message.
This is line of the message.
This is line of the message.
This is the last line of the message. ENDOFMESSAGE

嵌套方法为:

cat > /server/scripts/test2.sh << ENDOFMESSAGE

cat >>/etc/sysctl.conf<<EOF
net.core.wmem_default =
net.core.rmem_default =
net.core.rmem_max =
net.core.wmem_max =
EOF ENDOFMESSAGE #这样就创建了一个含有EOF的脚本

最新文章

  1. Git实用命令手册
  2. Yii源码阅读笔记(二十八)
  3. ITerm2下使用ssh访问Linux
  4. [游戏学习29] Win32 图像处理1
  5. Linux下可以替代windows的软件汇总:(不断完善中)
  6. linux下查看系统属性
  7. 仿IOS7日期选择控件(新)
  8. spring-cloud-feign负载均衡组件
  9. python&#160;标准类库-并行执行之subprocess-子进程管理
  10. 【转】关于高可用负载均衡的探索-基于Rancher和Traefic
  11. Weka算法Clusterers-Xmeans源代码分析(一)
  12. IO库----IO类,文件输入输出,string流
  13. 通过html文件生成PDF文件
  14. Python——面向对象(初级篇)
  15. Leetcode 96
  16. bzoj 1318 [SPOJ744] Longest Permutation (排列)
  17. 可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件
  18. spring 4.0+quartz2.2 实现持久化
  19. bzoj 4671 异或图——容斥+斯特林反演+线性基
  20. lintcode_177_把排序数组转换为高度最小的二叉搜索树

热门文章

  1. Ubuntu 18.04安装Conda、Jupyter Notebook、Anaconda
  2. Git之SSH公钥与私钥
  3. scrapy 爬取图片
  4. 浅谈C++ STL stack 容器
  5. SQL Server 迁移数据库 (四)备份和还原
  6. [PHP] 再续 Laravel 5.5 接口 跨域问题 【终极暴力解决办法】
  7. CF-579 D. &quot;Or&quot; Game
  8. flash判断,及安装注意
  9. Spring的工具类StringUtils使用
  10. kudu 查看元数据信息