Multiple Output Redirection

Sometimes you might prefer that the output from your command be placed in a file and be placed on stdout. The tee command provides this functionality. If you dwell on the name of the program—tee—you can almost visualize what the command does. Picture the output travelling up the vertical part of the letter “T”. When it reaches the top of the T, it splits the stream and the output goes in both directions (left and right). By default, the output will go to stdout and to the file whose name you specify at the end of the command syntax. The tee command can be used to redirect output to many places at once (not just two, as the name implies).

The following example directs the output of a ps command to files named xx and ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.