# How to duplicate stdout/stderr?

**URL:** <https://discourse.julialang.org/t/how-to-duplicate-stdout-stderr/42970>\
**Category:** General Usage\
**Created:** [July 13, 2020, 5:46am UTC](https://discourse.julialang.org/t/how-to-duplicate-stdout-stderr/42970 "2020-07-13T05:46:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 13, 2020, 8:37am UTC](https://discourse.julialang.org/t/how-to-duplicate-stdout-stderr/42970/2 "2020-07-13T08:37:57Z")

</div>

> [@Write to file and stdout](https://discourse.julialang.org/t/write-to-file-and-stdout/35042/3):
>
> This needs a lot more work to define a proper IO interface, but struct Tee{TIO \<: Tuple} \<: IO streams::TIO end Tee(streams...) = Tee(streams) function \_do\_tee(tee, f, xs...) for io in tee.streams f(io, xs...) end end Base.write(tee::Tee, x) = \_do\_tee(tee, write, x) Base.write(tee::Tee, x::Union{SubString{String},String}) = \_do\_tee(tee, write, x) print(Tee(stdout, stderr), "will appear twice")

---

_[View the full topic](https://discourse.julialang.org/t/how-to-duplicate-stdout-stderr/42970)._
