How can I redirect console output to file?

c, io-redirection, shell

Solution

Use shell output redirection

`your-command > outputfile.txt`

The standard error will still be output to the console. If you don't want that, use:

`your-command > outputfile.txt 2>&1`

or

`your-command &> outputfile.txt`

You should also look into the `tee` utility, which can make it redirect to two places at once.

Problem

I'm new to c. Is there any simple way to redirect all the console's output (printfs etc.) to a file using some general command line \ linkage parameter (without having to modify any of the original code)? If so what is the procedure?

Original source

Related problems