top | item 40765160

(no title)

kajika91 | 1 year ago

No pipe (and I mean in parallel too) no love for me.

Nice calling syntax though.

discuss

order

copirate|1 year ago

You can pipe with the `pipeline*` method of open3 which is part of the stdlib:

For example:

    require "open3"
    last_stdout, wait_threads = Open3.pipeline_r("cat /etc/passwd", ["grep", "root"])
    last_stdout.read # => "root:x:0:0::/root:/bin/bash\n"
    wait_threads.map(&:value).map(&:success?) # => [true, true]
https://ruby-doc.org/3.2.2/stdlibs/open3/Open3.html

e12e|1 year ago

Can you easily chain these, though? (gzcat some.txt|grep foo|sort -u|head -10 etc?). Especially lazily, if the uncompressed stream is of modest size, like a couple of gigabytes?

lucasoshiro|1 year ago

You can pipe using the backticks! Open irb and try this: `ls -l | wc -l`