Skip to content

Instantly share code, notes, and snippets.

@avdi
Created August 1, 2013 14:23
Show Gist options
  • Save avdi/6131832 to your computer and use it in GitHub Desktop.
Save avdi/6131832 to your computer and use it in GitHub Desktop.
Open3.pipeline_r(
%W[xmllint --xinclude --xmlout #{spine_file}],
# In order to clean up extraneous namespace declarations we need a second
# xmllint process
%W[xmllint --format --nsclean --xmlout -]) do |output, wait_thr|
open(codex_file, 'w') do |f|
IO.copy_stream(output, f)
end
end
@bf4
Copy link

bf4 commented Aug 1, 2013

Wait, this does what?

@kennethkalmer
Copy link

@rwjblue
Copy link

rwjblue commented Aug 1, 2013

So it is basically piping the output from the first command into the input of the second command then passing the output of the last command to the block.

So command_one | command_two > OUTPUT

Right?

@avdi
Copy link
Author

avdi commented Aug 1, 2013

Yep. And then IO.copy_stream pipes the output into a file. Yay!

@avdi
Copy link
Author

avdi commented Aug 1, 2013

The important thing is that these are real pipes - it's not collecting all the output from the first before it starts executing the second process.

@bf4
Copy link

bf4 commented Aug 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment