Duplicating stdout to stderr
Use process substitution: http://tldp.org/LDP/abs/html/process-sub.html
echo "FooBar" | tee >(cat >&2)
Tee takes a filename as parameter and duplicates output to this file. With process substitution you can use a process instead of filename >(cat)
and you can redirect the output from this process to stderr >(cat >&2)
.
If I may expand @defdefred's answer, for multiple lines I'm using
my_commmand | while read line; do echo $line; echo $line >&2; done
It has the "advantage" of not requiring / calling tee
and using built-ins.