How can I pipe the output of one program to another, but also have it appear on screen.
For example, to duplicate what winds up on the clipboard in dir | clip
, or to see what's happening along the way in longer chains.
If you have a copy of tee
that runs on Windows, such that dir | tee NUL | clip
loads the clipboard, but doesn't display anything on the screen (behaving as you would expect dir | clip
to), try dir | tee con | clip
. (con
is short for “console”; it’s Windows’ equivalent of /dev/tty
. nul
, naturally, is Windows’ equivalent of /dev/null
.)
/dev/tty
just did, but couldn't figure out how to write to the screen without it going stdout.
Jun 1, 2013 at 1:10
In Linux you have got tee
: Wikipedia - tee. You could install GNU core-utils for Windows: http://gnuwin32.sourceforge.net/packages/coreutils.htm
Example:
dir | tee clip
Should work just fine but I don't have Windows to try right now.
EDIT:
Another program - wintee You don't have to install coreutils (which I would advise to install anyway).
tee
will work just fine if command
accepts input fro SDTIN.
clip
. I tried dir | tee NUL | clip
which fills the clipboard, but doesn't display anything on the screen.
May 31, 2013 at 23:08
$?
, not sure where it is on Windows. But using2>&1
just merges it with stdout. I actually want to have stdout show up on the screen after being piped.2>&1
, andtee
or "splitting" are actually not even required for a solution. It was more of a question of how to use the redirection operators, and tee is just a convenience in that particular solution. In any case, don't think it would make sense to point every question about two-way stream splitting at that solution. If the question/solution were about that, then yes, but it's not.