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?
Redirecting OutputThe > symbol is used to redirect output by taking the output from the command on the left and passing as input to the file on the right.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With