小编Clo*_*ONG的帖子

如何在一个命令行中运行多个带有 & 的命令?

我遇到了一个头痛的问题。

我想在后台执行多个命令,所以我想在 bash 中一一启动它们。在后台启动linux shell中的一个命令很容易,就像这样:

myCommand &
Run Code Online (Sandbox Code Playgroud)

启动多个命令也很容易,就像这样:

myCommand1 && myCommand2
Run Code Online (Sandbox Code Playgroud)

或者

myCommand1 ; myCommand2
Run Code Online (Sandbox Code Playgroud)

但是如果我想在后台运行多个命令,我尝试了以下命令格式,但失败了:

myCommand1 & && myCommand2 &
Run Code Online (Sandbox Code Playgroud)

或者

myCommand1 & ; myCommand2 &
Run Code Online (Sandbox Code Playgroud)

两种格式都失败。如何&在一个命令行中运行多个命令?

command-line bash

13
推荐指数
2
解决办法
5万
查看次数

标签 统计

bash ×1

command-line ×1