在Bash中,我们可以使用“and”和“and-and”两种方式来执行多个命令。如何在同一行中同时使用这两个操作符呢?下面是一个示例:
do_something && do_another_thing & do_last_thing
在这个例子中,“do_something”和“do_another_thing”都必须成功执行,否则“do_last_thing”将不会被执行。而“do_another_thing”和“do_last_thing”则可以同时在后台运行。
另外,如果你想让所有命令都在后台运行,可以使用“and-and”操作符:
do_something && do_another_thing && do_last_thing &
在这个例子中,所有命令都会在后台运行,不会阻塞当前的Shell进程。
上一篇:Bash-nooutput