Well, sorry for the click-bait-ish title… Of course I meant this pee. It is similar to tee
in that it can “split” the input stream, but while tee
directs it to a few files (by default to stdout
and to the given ones), pee
directs it to pipes. You can give it names of commands and it will run them in succession and feed every one of them its input. (Unlike tee
, it doesn’t put it to stdout
, so you need an explicit cat
to achieve that.)
Here is a nice use-case. Assume you want to display the output of some command
, and below the output you want to display its line count. Here is a one-liner with pee
.
command | pee cat "wc -l"
And here’s another one. Imagine you have a large csv file and you want to grep it for some pattern. (Well, let’s also assume that there are no newlines in csv’s cells, since then one row no longer corresponds to one line.) The problem is, grepping would lose the header, which you want to avoid. Again, pee
to the rescue:
< file.csv pee "head -n1" "grep pattern"
What can I say? Happy peeing!