【问题标题】:Is nesting of Here Document possible in a unix bash script?可以在 unix bash 脚本中嵌套 Here Document 吗?
【发布时间】:2012-10-26 14:03:21
【问题描述】:

是否可以在另一个heredoc中编写heredoc?

ssh -T -q yxz@server1 <<-"END_TEXT"
.
.
    ssh -T -q abc@server2 <<-"SUB_TEXT"
    .
    .
    SUB_TEXT
.
.
END_TEXT

【问题讨论】:

    标签: shell unix heredoc


    【解决方案1】:

    是的

    但是,如果缩进是用实际的制表符完成的,嵌套的 heredoc 终止符只有在缩进时才会被识别。空间不起作用。

    所以你可能想做更多类似的事情:

    ssh s1 << \eof1
      ssh s2 << \eof2
        hostname
    eof2
    eof1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-08
      • 2014-10-11
      • 1970-01-01
      • 2012-06-08
      • 2014-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多