Open a terminal via gnome-terminal then execute co

2020-02-05 10:28发布

Via a bash command, I want open a terminal and, from the new terminal, execute a simple bash command.

I tried:

gnome-terminal -- "/bin/bash -c ls"

But I got this error:

enter image description here

I don't understand the error and I cannot find an example anywhere for help.

1条回答
兄弟一词,经得起流年.
2楼-- · 2020-02-05 10:40

The quotes are telling the terminal to run an executable in /bin called bash -c ls (with the spaces as part of its name!). There exists no such executable.

Take them out:

gnome-terminal -- /bin/bash -c ls

...or, to actually make something stay open until the user provides input...

gnome-terminal -- /bin/bash -c 'ls; read'
查看更多
登录 后发表回答