Print at terminal and copy simultaneously
command | tee output.txt Use case Rscript ~/shared/PallavCodes/TestCTK/code/test.R 2>&1 | tee shared/projects/CTKmodel/logs/CTKRun-`date +\%d-\%m-\%Y_\%H:\%M:\%S`.log