当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Julia pipeline方法用法及代码示例


用法一

pipeline(from, to, ...)

创建从数据源到目标的管道。源和目标可以是命令、I/O 流、字符串或其他 pipeline 调用的结果。至少一个参数必须是命令。字符串是指文件名。当使用两个以上的参数调用时,它们从左到右链接在一起。例如,pipeline(a,b,c) 等价于 pipeline(pipeline(a,b),c)。这提供了一种更简洁的方式来指定multi-stage 管道。

例子

run(pipeline(`ls`, `grep xyz`))
run(pipeline(`ls`, "out.txt"))
run(pipeline("out.txt", `grep xyz`))

用法二

pipeline(command; stdin, stdout, stderr, append=false)

将 I/O 重定向到给定的 command 或从给定的 command 重定向。关键字参数指定应该重定向哪个命令流。 append 控制文件输出是否附加到文件。这是 2 参数 pipeline 函数的更通用版本。当from 是命令时,pipeline(from, to) 等效于pipeline(from, stdout=to),当from 是另一种数据源时,pipeline(to, stdin=from) 等效于pipeline(to, stdin=from)

例子

run(pipeline(`dothings`, stdout="out.txt", stderr="errs.txt"))
run(pipeline(`update`, stdout="log.txt", append=true))

相关用法


注:本文由纯净天空筛选整理自julialang.org 大神的英文原创作品 Base.pipeline — Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。