O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.5. tee

The tee command acts the way it is pronounced. It takes the input and sends one copy to the standard output and another copy to a file. If you want to see your output and save it to a file at the same time, then this is the command for you.

The general format is:

tee -a files 

where, ‘-a’ means append all output to a file.

Tee comes in handy when you are running commands or scripts and you want to keep a log of the output.

Let’s look at an example. Using the who command, the output is sent to the screen and a copy is sent to a file called who.out.

						$ who | tee who.out louise pts/1 May 20 12:58 (193.132.90.9) matthew pts/0 May 20 10:18 (193.132.90.1) cat who.out louise pts/1 May 20 12:58 (193.132.90.9) matthew pts/0 May 20 10:18 (193.132.90.1) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required