Bash gnu并行:同步输出?

Bash gnu并行:同步输出?,bash,parallel-processing,synchronization,gnu-parallel,Bash,Parallel Processing,Synchronization,Gnu Parallel,我正在运行一个gnu并行作业,如下所示: parallel program ::: 1 2 3 4 5 6 7 8 9 10 > output.txt 我想保证输出文件是有序的。也就是说,第一行对应于程序1的输出,下一行对应于程序2的输出,等等 我如何保证这一点?我认为-k选项可能就是您想要的: 在手册页的前一个示例中,输出是1234,而后者确实产生2143 --keep-order -k Keep sequence of output same as the ord

我正在运行一个gnu并行作业,如下所示:

parallel program ::: 1 2 3 4 5 6 7 8 9 10 > output.txt
我想保证输出文件是有序的。也就是说,第一行对应于
程序1的输出,下一行对应于
程序2的输出,等等


我如何保证这一点?

我认为
-k
选项可能就是您想要的:

在手册页的前一个示例中,输出是
1234
,而后者确实产生
2143

 --keep-order
   -k       Keep sequence of output same as the order of input.
            Normally the output of a job will be printed as soon
            as the job completes.
            Try this to see the difference:
              parallel -j4 sleep {}\; echo {} ::: 2 1 4 3
              parallel -j4 -k sleep {}\; echo {} ::: 2 1 4 3