Technology and General Blog

Although applying a Linux terminal, there exist numerous circumstances exactly where you want to redirect the output of a command to a file and display screen at the same time, making certain that the output is penned to a file so you can refer to it later. You will be delighted to know that a Linux device can carry out this purpose easily. “tee command” is added in the Linux-based units specially for this function. So, let’s go forward and master about this wonderful software.

tee command:

tee command can go through the typical input and redirect it to one or a lot more files. It breaks the output of any command or plan revealed on the screen and saves it to a file. It is utilized with other commands making use of pipes.

tee command primary syntax:

Right here we have demonstrated you the basic syntax of the tee command.


  • -i or –ignore-interrupts is for ignoring interrupt alerts.
  • Eventually, -a or –append allows tee command to append files alternatively than overwriting the information.
  • You can also use tee -enable to check out the record of obtainable selections for the tee command.


  • File names of just one or additional documents. Each of these data files will have the redirected output.

Applying tee command for redirecting output to file and display screen:

This portion contains some fantastic illustrations for demonstrating the output redirection of any command to a display screen or any file.

Syntax of tee command for redirecting output:

command | tee /path/to/file

Redirecting output to a single file and monitor:

In the terminal, executing the “ls” command will record the information and directories existing in your latest doing work directory.

For redirecting the output to a file and display screen simultaneously, generate out the tee command in the next way:

Just before the “|” pipe image, you can type the command you want to execute and then incorporate the “|” with the tee command even though specifying the file route. In our scenario, we will redirect the output to “samplefile” existing in our household directory.

You can also append the redirected output by employing the “-a” or “–append” possibility with the tee command. -a or –append possibility permits tee command to append documents somewhat than overwriting the file’s information.

Syntax for appending redirected output:

command | tee -a /route/to/file

This command will append the redirected output to the close of the “samplefile.”

$ uname -a | tee -a samplefile

Redirecting output to Numerous data files and display:

If you want to redirect the display screen output to many files, the only matter you have to do is increase the file names at the finish of the tee command. We have offered you the syntax for this many file redirection.

command | tee file1 file2 file3

The beneath-specified command will redirect the output of “ls” to display screen and “samplefile.txt” and “samplefile2.txt” files.

$ ls | tee samplefile.txt samplefile2.txt


When functioning in the Linux terminal, the thought of output redirection is treasured. “tee” command is just one of the most useful equipment that assists a Linux person redirect the output of a command to a file and monitor. This short article talked over the most important use of “tee” for redirecting output to display, single, or multiple documents.

Leave a Reply

Your email address will not be published. Required fields are marked *