Variables 通过ssh回送多行变量内容
我试图通过ssh回送多行变量,但第二行作为命令执行Variables 通过ssh回送多行变量内容,variables,ssh,echo,Variables,Ssh,Echo,我试图通过ssh回送多行变量,但第二行作为命令执行 msg=“你好世界;你好世界2”;echo$msg;ssh-q newhost“echo”$msg”“ 输出: Hello World; Hello World2 Hello World bash: Hello: command not found 是否有理由将其设置为多行变量?为什么不发送两条不同的消息呢 msg="Hello World"; msg2="Hello World2"; echo $msg; ssh -q loca
msg=“你好世界;你好世界2”;echo$msg;ssh-q newhost“echo”$msg”“
输出:
Hello World; Hello World2
Hello World
bash: Hello: command not found
是否有理由将其设置为多行变量?为什么不发送两条不同的消息呢
msg="Hello World"; msg2="Hello World2"; echo $msg; ssh -q localhost "echo "$msg""$msg2""
很好
echo-e将允许您解释转义字符,如\n,您应该使用它来代替分号 如果您设置为多行,我刚刚发现echo-e Hello\nWorld可能会提供您所需的内容;echo-e$msg;我在主题中提供的示例是我正在尝试做的简单版本。实际上,我有一个包含大量命令的文件。我将该文件中的内容分配给一个变量,并尝试通过ssh在不同的主机上回显它。这就是为什么它应该在一个多行变量中。但不是回显它,而是执行文件中的所有命令;回声-e“$A”;ssh-q newhost01“echo-e$A”主机名;hostname主机名newhost01能否使用换行符而不是分号\n代替;