Suppose you just updated your address book file and want to send it to your boss in addition to putting it in your own files. You can, using tee, which redirects output to two different places (see Code Listing 6.19).
sort address.book new.addresses → | tee sorted.all | mail → [email protected] -s "Here"s the → address book, boss" -
At the shell prompt, use the tee command plus a filename in the middle of the pipe line to send the sorted information to that filename as well as to the standard output (which could, of course, be redirected to another filename). Here, we send the results of the sort to the sorted.all file and to standard output, where mail will take over and send the file to the boss. See Chapter 11 for more on fancy mail tricks.
Tee Time?You might think of the tee command as being similar to a plumber’s pipe joint— that is, it takes stuff from one location and sends it out to two different places. |
[ejr@hobbes manipulate]$ sort address.book new.addresses | tee sorted.all | mail → [email protected] -s "Here's the address book boss" - [ejr@hobbes manipulate]$ |