Linux tee command explained with examples
Introduction We may often find ourselves in situations wherein we are running some commands on our Linux/UNIX operating system and we need to display the output of the command to our terminal and save it to a file for future use as well. The Linux tee command is a utility that is meant to be used for precisely this purpose. We have already provided a quick introduction to the tee command in one of our earlier articles. In this article, we will discuss the different ways in which we could use the tee command in greater detail by means of practical examples. The tee command is part of the coreutils package and therefore should be installed on almost every Linux distribution out there. We’ll be using a Centos 6 machine for demonstrating the examples in this article. Example 1: Using tee command directly For our first and basic example, we’ll type the tee command followed by a file name and press enter. From hereon in anything we type on the terminal is redirected back to the terminal in the form of stdout and redirected to the file whose name we specified while invoking the tee command. Here is a demonstration. [root@linuxnix ~]# tee myfile.txt this is a basic tee command usage example this is a basic tee command usage example [root@linuxnix ~]# [root@linuxnix ~]# cat myfile.txt this is a basic tee...
Read More