bash - 如何打开一个新终端并运行两个linux命令?

标签 bash shell

我创建了一个 .sh 脚本,其中包含打开终端的选项,并且同一终端运行 2 个命令。 我知道打开一个新窗口或选项卡并运行命令,但是当我输入 && 时,我使用此命令收到如下错误:

命令:

gnome-terminal --tab -- "ls && clear"

错误:

There was an error creating the child process for this terminal
Failed to execute child process “ls && clear” (No such file or directory)

我的操作系统是Linux(Ubuntu)

最佳答案

gnome-terminal 需要命令名称。它查找字面上称为 ls && clear 的命令,但找不到它。您需要在 shell 中运行它:

gnome-terminal --tab -- bash -c "ls && clear"

关于bash - 如何打开一个新终端并运行两个linux命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56448239/

相关文章:

bash - SSH远程命令执行脚本

linux - Makefile 警告和错误的颜色突出显示

shell - FastCGI shell 脚本

linux - BASH If [[ "$a"== *"$b"* ]] 始终为真,即使它不应该为真

mysql - 如果Ubuntu中没有PID(进程ID),请重新启动MySQL服务

C mini shell,处理 SIGCHLD 的问题

python - 使用 Selenium 进行测试时如何调整 Chrome 和 Firefox 中的窗口大小?

linux - 使用 find 使用随机字符递归重命名文件

linux - 有什么方法可以阻止后台输出在 Linux 终端中分解输入?

java - 从 Ruby 脚本执行 Ruby Gem