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

3 Answers 3


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.

  • 1
    Indeed, in the pipeline you show /dev/stdout is redirected. That is, if you were using tee /dev/stdout the effect would be that everything is sent to xargs twice, and nothing goes to the terminal.
    – celtschk
    Apr 30, 2014 at 14:37
  • /dev/stdout is not redirected by a pipe, it will stay the current process standard output. However, if you encapsulate the command in a script and then redirect the stdout of this script, then /dev/stdout will be redirected. In an interactive console, tee /dev/tty and tee /dev/stdout has the same effect, even when using pipes. Apr 30, 2014 at 17:24
  • If you don't believe me, start your shell and type echo foo | tee /dev/stdout | tr f b and echo foo | tee /dev/tty | tr f b. Here's a hint for you: It is tee which interprets the /dev/stdout as file name.
    – celtschk
    Apr 30, 2014 at 17:31
  • 2
    You are right, I do not know how I missed that. I did some tests in my own shell with tty and stdout and I do somehow missed that. Thanks for the clarification, I removed the wrong statement. Apr 30, 2014 at 18:05
  • Well, given that stderr is not affected by the pipe, you would not have needed to remove that (of course the script redirection caveat remains, but for a script, redirectability would generally be a desired property).
    – celtschk
    Apr 30, 2014 at 19:07

A more general solution than /dev/tty:

start cmd:> echo foo | tee /dev/stderr 

You can use tee command, just feed it with STDERR file, as example:

tee /dev/stderr
tee /proc/self/fd/2

so in that case your alias maybe:

git status --short | \
    cut -b4- | tee /dev/stderr | \
    xargs gvim --remote
  • 1
    I think you mean /proc/self/fd/2
    – celtschk
    Apr 30, 2014 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.