What tee command? It will show output on the terminal and even the file is getting save into a specific location and you do not need to create a file it will automatically generate.
To get into more detail we will use this “tee” command to demonstrate.
command | tee filename.txt
We will use hostnamectl command to show machine details with tee to save output into trendoceans.txt
How to append output using tee command?
If you want to save file output again and again into same file then you have to append the file.
In case you have just tee with the option then file we will get overwritten, To get into more detail we will use this “tee -a” command to demonstrate.
command | tee -a filename.txt
You can see in picture both the output are save in single file
Now we will show you how you can save error output and standard output into a file.
Syntax without append
command | &tee filename.txt
Syntax with append
command | &tee -a filename.txt
Like this way you can save error and standard using |& tee command.
We have guided how to use the redirect symbol and tee command to save command output into a file.
There are combination of redirection symbol which you can use like “>” ,“>>”,“&>”,”&>>.
Combination of tee command |tee, |tee -a, |&tee, |&tee -a.
Let’s us know If you want to know much about any specific topic.
Through all the above method, you can save the command output from the Linux terminal.
Innovative tech mind with 10 years of experience working as a computer programmer, web developer, and security researcher. Capable of working with a variety of technology and software solutions, and managing databases.