Reusing stdout


stdout is nice–it let’s you see what’s going on. But what if you want to see what’s going on and also do something else with the same output.

tee is useful for redirecting stdout to a file, but what if you want to send the same output to another command too, like mail?

You disguise the command as a file, that’s what. Through process substitution you can say things like

echo "hello world" | tee >(mail -s "notice")

and have the message go to stdout and your mail program. You can chain process substitutions to do as many different things with the same output as you want.

Process substitution is supported in bash and friends, but not, as far as I can see, in sh.

No Comments

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a comment


powered by WordPress     themed by Mukkamu     presented by ideaharbor.org     everything else by steve hulet