How to log to file and to console
try using tee
?
| tee log.txt
instead of
> log.txt
There are various ways by which you can make log. But the first and the foremost thing is what actually you want to put in your log. You can do that in various ways:
Tee command splits the output of a command so that it can be seen on the display and also be saved in a file.
command | tee log.txt
The above command will display the output to terminal as well as it will redirect the output to the file
log.txt
.The script command makes a typescript(copy) of everything printed on your terminal:
script -a log.txt
Use the tee
command:
some_command | tee log.txt