GNU Parallel:如何从gnu并行管道接收stdin,就像它来自文件一样?

问题描述 投票:1回答:1

假设我有以下命令运行如下:

my_command -f file

如何设置并行以使管道内容像管道一样被执行?

# For example, in pseudo code: 

cat item | parallel my_command -f <(the incoming stdin)

这样做非常重要,因为我正在通过--speadstdin选项处理特定的数据块,所以如果有一种方法可以将管道输入重定向,就像它来自文件一样,那将解决这种情况。

gnu-parallel
1个回答
1
投票

您正在寻找--cat--fifo

cat file | parallel --pipe --cat my_command -f {}

更快,但要求my_command从头到尾一次只读一次完整的文件:

cat file | parallel --pipe --fifo my_command -f {}

更快,但需要file是一个真实的文件:

parallel -a file --pipepart --block -1 --fifo my_command -f {}

另见GNU Parallel 2018中的第9.6章(在线:https://doi.org/10.5281/zenodo.1146014印刷:http://www.lulu.com/shop/ole-tange/gnu-parallel-2018/paperback/product-23558902.html)。

© www.soinside.com 2019 - 2024. All rights reserved.