Save terminal output to a file


All output will be sent to terminal and file.

bash-4.2$ command |& tee output.txt

Append to existing file

bash-4.2$ command |& tee -a output.txt

Source: Stackoverflow