Skip to content
Advertisement

Echo to both stdout and stderr

I have a probably pretty easy beginner question: How do I echo from a shell script into both stdout and stderr? I know that I can echo to stderr echo "foo" 1>&2 but I need the output in both. I tried some Googling but nothing worked.

Advertisement

Answer

This should do it

 echo "foo" | tee /dev/stderr 
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement