moreutils completes the shell's toolbox

Slashdot it! Delicious Share on Facebook Tweet! Digg!

pee

The rude sounding pee command was also developed for use in pipes. This is the counterpart to the file-oriented tee command (Listing 11). tee outputs the output of a script or program to two files and STDOUT . pee , on the other hand, distributes the output to two pipes (so it can be used by another program) and omits it on STDOUT .

Listing 11

Pipes with pee

$ ./script.sh | tee output1.txt output2.txt
$ ./script.sh | pee "grep pattern" "gzip -c > output.gz"

vipe

The vipe program makes it possible to use editors between pipes (Listing 12). At first glance, this might seem to be of limited value since pipes connect the STDOUT channel of the first command to the default input of the second command. Sometimes it makes sense to edit data before the processing continues in order to save storage along the way. vipe first reads in the entire dataset, processes it, and then passes the results on after the editor is finished. As with vidir , vipe also evaluates the variables EDITOR and VISUAL as part of designating the editor.

Listing 12

Editing with vipe

$ man less | vipe | cat
LUTHER(1)        General Commands Manual        LUTHER(1)
NAME
       luther - opposite of pope
COPYRIGHT
       Copyright (C) 1517-2016 by the Lutheriden
AUTHOR
       Faked 2016 by Joerg Luther <jluther@linux-user.de>
                 Version 499: 28 Nov 2016        LUTHER(1)

Buy this article as PDF

Express-Checkout as PDF

Pages: 7

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content