Linux Bash,命令'gnome-terminal'中转义引号

3

我从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-terminal命令中执行简单的echo并避免引号?

谢谢:)

1个回答

3

试试这个:

test="foo\'s"
gnome-terminal -- bash -c "echo \"$test\"; sleep 10"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接