The Mighty Named Pipe
vincebuffalo.com
The Mighty Named Pipe
1–10 of 99 posts
Re: The Mighty Named Pipe
#2Or even if you think you know unix/bash and data there are new and unexpected snippets every few pages that surprise you.
Re: The Mighty Named Pipe
#3Re: The Mighty Named Pipe
#4For example (from Wikipedia)
tee >(wc -l >&2) bigfile.gz
vs
tee bigfile.gz
Re: The Mighty Named Pipe
#5I only discovered process substitution a few months ago but it's already become a frequently used tool in my kit.
One thing that I find a little annoying about unix commands sometimes is how hard it can be to google for them. 'Unless you know to look for "Process Substitution" it can be hard to find information on these things. And that's once you even know these things exist....
Anyone know a good resource I should be using when I find myself in a situation like that?
Re: The Mighty Named Pipe
#6How does the > process substitution differ from simply piping the output with | ? For example (from Wikipedia) tee >(wc -l >&2) bigfile.gz vs tee bigfile.gz
Re: The Mighty Named Pipe
#7How does the > process substitution differ from simply piping the output with | ? For example (from Wikipedia) tee >(wc -l >&2) bigfile.gz vs tee bigfile.gz
so:
cmd1 | tee out.txt | cmd2
So tee is splitting the stream into two outputs, one that carries on out stdout (into cmd2) and the other one that is redirected into out.txt.With process substitution you can do extra stuff on the way out, I guess (I've never seen it used for output before).
It looks like in the example given they're writing wc stuff to stderr while zipping the content (over stdout).
Nice to see that example, I hadn't even thought about the usefulness of process substitution for outputting like this!
Re: The Mighty Named Pipe
#8Nice article. Really easy to follow introduction. I only discovered process substitution a few months ago but it's already become a frequently used tool in my kit. One thing that I find a little annoying about unix commands sometimes is how hard it can be to google for them. ' Unless you know to look for "Process Substitution" it can be hard to find information on these things. And that's once you even know these thi…
$ man bash
/
Drops you right into the Process Substitution section.Re: The Mighty Named Pipe
#9Re: The Mighty Named Pipe
#10How does the > process substitution differ from simply piping the output with | ? For example (from Wikipedia) tee >(wc -l >&2) bigfile.gz vs tee bigfile.gz
but since the output is huge and your disk is old and dying, you want to run xz on it before saving it to disk, so use >(): (xz - > out1.txt) -o2 >(xz - > out2.txt)
If you want to do several things in there, I recommend defining a function for clarity: pp () { sort -k2,3 -t$'\t' | xz - ; }
(pp > out1.txt) -o2 >(pp > out2.txt)