删除机器文件中不替换变量值

时间:2016-05-27 05:58:45

标签: bash ssh

当我们使用单引号或双引号时,在删除机器文件中不会替换变量值。

有什么问题?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="url"></div>
<a href="#reportControlPanel1">"Open" panel 1</a>
<a href="#reportControlPanel2">"Open" panel 2</a>
<div id="reportControlPanel1" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
  <div id="promptPanel" class="pentaho-rounded-panel-bottom-lr">
    this is some text in the first control panel.
  </div>
</div>

<div id="reportControlPanel2" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
  <div id="promptPanel" class="pentaho-rounded-panel-bottom-lr">
    this is some text in the second control panel
  </div>
</div>

预期:

echo '${machineIP}\t${fullMachineName}\t${machine}' | \
  `ssh root@${fullMachineName} "cat >> ${hostsFilePath}"`

echo "${machineIP}\t${fullMachineName}\t${machine}" | \
  `ssh root@${fullMachineName} "cat >> ${hostsFilePath}"`

实际值:

10.10.20.30 tab machine.lab.com tab machine.lab

1 个答案:

答案 0 :(得分:2)

您需要为echo命令启用-e参数。

echo -e "${machineIP}\t${fullMachineName}\t${machine}" 

这会将\ t转换为&lt; TAB&gt;炭。

从手册:

  

-e启用反斜杠转义的解释