8/21/2018 - 10:40 AM

Redirect all console output to a file

The output of a program could be send to stderr or stdout. In the case you want to manage both separatelly:

foo > stdout.txt 2> stderr.txt

or if you want in same file for both message streams:

foo > allout.txt 2>&1

You can also maintain the regular output using 'tee' to split the data flow:

foo 2>&1 | tee allout.txt

Note: this works in (ba)sh, check your shell for proper syntax

source: https://stackoverflow.com/a/6674348/1407528