IO Redirection – How to Tee stdout to stderr

io-redirectionstdinstdouttee

I'd like to send stdout from one process to the stdin of another process, but also to the console. Sending stdout to stdout+stderr, for instance.

For example, I've got git edit aliased to the following:

git status --short | cut -b4- | xargs gvim --remote

I'd like the list of filenames to be sent to the screen as well as to xargs.

So, is there a tee-like utility that'll do this? So that I can do something like:

git status --short | \
    cut -b4- | almost-but-not-quite-entirely-unlike-tee | \
    xargs gvim --remote

Best Answer

tee can duplicate to the current console by using tee /dev/tty

git status --short | cut -b4- | tee /dev/tty | xargs gvim --remote

Alteratively, you can use /dev/stdoutor /dev/stderr but they could be redirected if your command is within a script. Note that /dev/tty will always be the console (and may not exist in a non-interactive shell). This is wrong, read the comments.

Related Question