How to redirect stdout / stderr to a file

Redirecting all your program output to a file is very simple and can be accomplished like this: myapp > output.log This line will send all the output generated by myapp to a file named output.log. The contents of output.log will always be overwritten; but you can use a second > to append to the current content like this: myapp >> output.log As well as with output, it is very useful to redirect the stderr (standard error output) to a file rather than to the screen.