I have a necessity for that usage, I googled for it, found an answer here on UNIX.com, but I thought, there might be something slicker. I got myself an account there in order to tell the initiator of that thread, what I am going to find out, but sadly enough, he got banned since. That doesn’t happen too rarely.
I like UNIX man pages, and I thought, I should give “$ man 1 tee” a try. That pointed me to “$ info coreutils ‘tee invocation‘”, and that instructed me to use “process substitution“, a feature of modern shells. The notation is different, but it’s still piping: “>( PROCESS_READING_FROM_A_PIPE )“. And you can use it more than once on the process, that you want to read output from.
Now, that is seriously slick enough for me. Read the example there, it’s really nice!
Added a note on en.wikipedia.org mentioning this insight.
It is rather tempting to think, that using process substitution you don’t even need tee itself anymore at all, but just try yourself, it doesn’t work!
Leave a Reply