Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 15 down vote accepted

Here's what you can do with pee:

seq 5 -1 1 > file
cat file |pee 'sort -u > sorted' 'sort -R > unsorted'

So pee works with shell pipes instead of files.

bash doesn't need pee, it can open shell commands as files:

cat file |tee >(sort -u > sorted) >(sort -R > unsorted)
share|improve this answer
Would this work with filename jockers ? See zgp.org/~dmarti/tips/git-multiple-post-receive-hooks - pee is used to multiply stdin and give clones to every script mathing the filename pattern, can pure bash do this ? AFAIU it would expand asterisk inside the brackets causnig something like tee >(app1 app2 app3 app4) which is not >(app1) >(app2) >(app3) >(app4) that your answer shows –  Arioch 'The Nov 4 '12 at 13:59
@Arioch, the bash syntax won't work with the hooks-joker technique. Just install moreutils. –  Tobu Nov 4 '12 at 23:40
Use tee >/dev/null to avoid replicating stdin to stdout –  J.F. Sebastian Jan 6 at 11:59
add comment

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:

echo "Hello world" | tee one two

Will create two files, named one and two, both containing the string Hello 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 from tee 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:

echo "Hello world" | pee cat cat

Will output the string Hello world to your terminal twice. This is because each of the two instances of cat receives the standard output and does what cat does, which is print.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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