I am working with a python logging script which is interactive (requires user inputs at times) and would like the output to be both in my terminal shell as well as to a text file. The logging is very verbose, so I can't just copy from the shell as some go past the terminal history.
I was wondering if there was a way to do this. I'm even open to executing a separate shell script which calls the python script if that enables things easier.
The tee
command (part of coreutils) does that. Example usage:
the_script.py | tee the_script.log
This will write the script output (STDOUT) to the log file and STDOUT.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.