bash - 并行运行文件中的 bash 命令列表

标签 bash concurrent-processing

我有一个简单的文本文件 (command_script.txt),我将其作为 bash 脚本执行。

command_script.txt的内容是这样的:

#!/bin/bash
some_command -flags input1 output1
some_command -flags input2 output2
some_command -flags input3 output3
...
some_command -flags input1000 output1000

我在命令行(./command_script.txt)上执行它,它一次运行一行。有没有一种简单的方法可以同时并行运行 20 条线?

谢谢!

最佳答案

通过在行尾附加“&”,进程会在后台启动。因此,下一个会立即启动,以便两者并行运行。

关于bash - 并行运行文件中的 bash 命令列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71287579/

相关文章:

bash - 当传递给 sed 或 awk 时,冗长的管道命令输出挂起

regex - 使用 bash 计算模式之间的行数/字符数

Scala actor 作为单线程队列

Python多线程方法

linux - bash 通过 ssh 在远程主机上运行多个命令

linux - 如何使用 bash 脚本中的变量在谷歌浏览器中运行 url

c# - 如何避免在并发数据处理期间耗尽 RAM?

asynchronous - 如何均衡处理多个并发任务?

linux - 从 perl 启动 bash 时命令失败,但从命令行启动时没有,权限问题