GNU Parallel:如何从 gnu parallel 管道接收标准输入,就好像它来自文件一样?
GNU Parallel: How to recieve stdin from gnu parallel pipe as if it were from a file?
假设我有如下运行的命令:
my_command -f file
如何设置并行,以便管道输入的内容像管道一样执行?
# For example, in pseudo code:
cat item | parallel my_command -f <(the incoming stdin)
这样做很重要,因为我正在通过 --speadstdin
选项处理特定的数据块,所以如果有一种方法可以重定向管道输入,就好像它来自文件一样, 这样就可以解决问题了。
您正在寻找 --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 Printed: http://www.lulu.com/shop/ole-tange/gnu-parallel-2018/paperback/product-23558902.html)。
假设我有如下运行的命令:
my_command -f file
如何设置并行,以便管道输入的内容像管道一样执行?
# For example, in pseudo code:
cat item | parallel my_command -f <(the incoming stdin)
这样做很重要,因为我正在通过 --speadstdin
选项处理特定的数据块,所以如果有一种方法可以重定向管道输入,就好像它来自文件一样, 这样就可以解决问题了。
您正在寻找 --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 Printed: http://www.lulu.com/shop/ole-tange/gnu-parallel-2018/paperback/product-23558902.html)。