I recently discovered the 'moreutils' package in Debian (and Ubuntu). It's a collection of convenient unix tools.
One of the commands is 'pee'. The man page says:
pee is like tee but for pipes.
However it's a short man page, I have filed a bug about it. Does anyone know what it does, how to use it, why one would use it?
Here's what you can do with pee:
So pee works with shell pipes instead of files.
bash doesn't need pee, it can open shell commands as files:
It's probably easier to understand if you've used
tee
first. This useful old tool takes standard input and writes out to multiple files, plus standard output. The following:Will create two files, named
one
andtwo
, both containing the stringHello world
. It will also print to your terminal.Now
pee
performs a similar function but instead of redirecting output to multiple files it redirects to multiple secondary commands, ala pipes. It differs slightly fromtee
in the respect that it doesn't send the original stdin to stdout because it wouldn't make sense combining it with the output of the secondary commands. The following very simple example:Will output the string
Hello world
to your terminal twice. This is because each of the two instances ofcat
receives the standard output and does whatcat
does, which is print.