在 linux 中,我通过命令“gnome-terminal”打开终端并运行一些这样的命令:
test="foo";gnome-terminal -- /bin/bash "echo $test"
现在,我想运行一个包含这样的引用的回显:
test="foo\'s";gnome-terminal -- /bin/bash "echo $test'"
但这不起作用..反斜杠似乎没有任何作用。我试过其他语法:
test="foo\\'s";gnome-terminal -- /bin/bash "echo $test"
test="foo\\\'s";gnome-terminal -- /bin/bash "echo $test"
...
如何从 gnome 终端命令中执行的简单 echo 中转义引用?
谢谢你:)
最佳答案
试试这个:
test="foo\'s"
gnome-terminal -- bash -c "echo \"$test\"; sleep 10"
关于bash - linux bash,命令 'gnome-terminal",转义引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48814603/