Duplicating StdErr

In case you would ever like to duplicate standard output to log the stream of data while processing it, tee is your friend:

{
	echo stdout
	echo stderr >&2
} 2> >(tee >(cat >stderr1) >stderr2)

NOTE: The output will is not synchronized line-wise. So redirecting both lines of processing into the same file (using >>) will cause the individual results to be garbled.

Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.