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



我有一个简单的文本文件(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行?

谢谢!

通过附加"amp"在一行的末尾,一个过程在后台启动。因此,下一个将立即启动,以便两者并行运行。

#!/usr/bin/parallel --shebang -j20
some_command -flags input1 output1
some_command -flags input2 output2
some_command -flags input3 output3
...
some_command -flags input1000 output1000

如果命令在文字上是给定的命令,那么您可以执行以下操作:

seq 1000 | parallel -j20 some_command -flags input{} output{}

最新更新