

$ cat file2.txt Example 3) Suppress output of tee command

Once again, you can confirm the existence of the output in the two files using the cat command as shown: $ cat file1.txt In the following example, we have invoked the hostnamectlcommand to print the hostname of our system among other details and save the standard output to two files file1.txt, and file2.txt $ hostnamectl | tee file1.txt file2.txt
Sudo cat tee free#
In the example below, the command we are inspecting the block devices in our system and piping the results to tee command which display the output to the terminal while simultaneously saving it on a new file called block_devices.txt $ lsblk | tee block_devices.txtįeel free to examine the contents of the block_devices.txt file using the cat command as shown: $ cat block_devices.txt Example 2) Save command output to multiple files using teeĪdditionally, you can write a command’s output to several space-separated files as shown in the syntax below.

Example 1) Basic usage of tee commandĪs described earlier, the main function of the tee command is to display the output of a command (stdout) and save it in a file. With that in mind let’s check out a few examples on how the command is used. In tee command’s syntax, filename refers to one or more files. Here are some of the options that you can use with tee command:
