'Saving script output in a file but showing the output on the terminal too [duplicate]

I have a small workflow formed by one run.sh script that automates a few scripts.

In this run.sh I have a function to run some INFO and ERROR messages and save it in a log.txt file but the scripts also generate outputs. I would like to save these outputs in another log file and also see the output when I run the pipeline.

I run my pipeline with this command.

run.sh -f1 a file -f2 other file -d a/directory.

I have seen I can do that as explained in this link

But as long as I know this will not show me the output in the terminal.

How can I get output in the terminal and also save it in a file? I am using a cluster computer and the output in the terminal is not saved if I lost the conection or log off from my PC.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source