I want to save the terminal output as a file and also see the output immediately. There are a lot of related questions but the answers are not satisfying. For example,
my_command > output.txt
does not print output to terminal. Another answer, which is
my_command | tee output.txt
prints output to terminal after the process is completed, not immediately. Although I can append each line when I print the output in python code, but this does not seem to be a right way to solve issue.
Update: it seems that tee
flushes output to terminal with certain amount of units.