Linux Command: 'tee' - Watch & Log Command Output

preview_player
Показать описание
The 'tee' command allows you to monitor a command's output in your shell (or piping that output to another program) while *also* writing it to a logfile. Now you can have your Linux cake and eat it, too!

Рекомендации по теме
Комментарии
Автор

You might have wanted to mention the magic of "2>&1 " before piping because without this it only pipes the STDOUT but with this it pipes STDOUT and STDERR. Considering the most common use-cases, this is probably a must-know.

tobara
Автор

Perfect explanation of "tee" to a tee!

MFM
Автор

Thank you so You explained this better to me than ANY other person or course! Thank you!!!!

kylabutler
Автор

alias tea='tee -a'

Unless you have the test editor "tea" installed. :-)

DanielSMatthews
Автор

Another tip on this command:
Good to redirect the output to a process run as another user.

Simple example when logged in as a normal user:
This will not work: sudo echo "myawesomecomputername" > /etc/hostname
This do work: echo "myawesomecomputername" | sudo tee /etc/hostname

Sure there are many other ways to to this particular example. The point being is that one sometimes need to run something as a user, but need to process the output as another user. tee will help there.

sysghost
Автор

cool, this would be great for something like sudo watch tail -f /var/log/syslog | tee -a bla.txt if you wanted to capture just the output of a specific configuration change or problem for reviewing later. Thanks for the great tip!

OddRandomThoughts
Автор

nice, Unix/ Linux every day something new to learn.

gaithalbadarin
Автор

Neat little video. Now I will use tee. Thanks.

Man, all these videos are super useful, and great quality. Especially love the series on Python 3.
Thanks a lot.

JustinC
Автор

Another nice use case is when you want to log an interactive command, so something where you get asked stuff once in a while (username or password for example). Even though the script command might be more useful in that scenario.

fifothebot
Автор

Your videos deserve my subscription, thanks.

OddBallTrails
Автор

Hey, thanks for the cool tutorial... but can you also explain what are those green/red arrows on the left side of your prompt?!
What terminal are you using? Isn't it GNOME's "terminator" by any chance?

SamSharifian
Автор

So, I have a raspberry pi, and on it it's only been command lines running, I now noticed that I have a full log somewhere with every commands used since like 2 years back, but I can only see one at a time, I want to be able to ... download a file which i can skim through to find what commands I used back then, because I don't remember, I have my bots on it, and that's it basically. "/

QuestionTheTruth
Автор

Thanks for a video, though it looks more like one of the "Hello world" one...
Would love to see the use of this command along with some python/bash script, to actually show it's usefulness and convince me to use it. We need more high level stuff! :) Still thanks ;-)

Steeldragon
Автор

Awesome! more video like this please :3

modern__ninja
Автор

An interesting feature would also be to save the command itself.

zapy
Автор

I`m a newbie in Linux, but for this purpose of writing the output to a file I could just use nohup right!?

baleia
Автор

Thus I can write to multiple files like: date | tee f1 | tee f2 | tee f3 > f4

micmac
Автор

ooph....popping those P's almost broke my speakers....do you have a governor on your mic

AnonymousAccount
Автор

For whole shell output to a file Try using script command, use like this --> script /home/user/myWork.out now whatever u do will be logged in this file, press "ctrl+c" to exit from this script output and come back to your Shell !!!!

danydanger
Автор

how to tee 'tail -f /var/log/kern.log | grep XXX' ?

JohnnieWalkerGreen