bash - linux bash,命令 'gnome-terminal",转义引号

标签 bash gnome-terminal

在 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/

相关文章:

regex - bash regex for word with some suffixes 但不是一个特定的

linux - 测试文件内容

linux - Fish shell 无法正确渲染符号

ubuntu - 在 gnome-terminal/bash 中,std 输出可以作为命令直接运行(解释吗?)?

linux - Gnome 终端 Linux 脚本

regex - 使用终端 man 命令阅读手册页中的部分

linux - Linux 上的 sed 与 FreeBSD 上的 sed

linux - mv 命令创建目录

linux - 语言/库来做简单的控制台用户界面?

linux - gnome-terminal 从文件中执行命令