Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I redirect console output to file?

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?

like image 630
vondip Avatar asked Nov 22 '13 22:11

vondip


People also ask

How do you redirect output?

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.


1 Answers

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.

like image 106
Hut8 Avatar answered Sep 23 '22 12:09

Hut8