Redirect Output To File (stdout and stderr)

September 4, 2017
command > output.log 2>&1

Redirect both stdout and stderr to file.

command > output.log 2>&1

Use >> for append instead of overwrite.

command >> output.log 2>&1

Without 2>&1 it will capture stdout only.

command > output.log

The folowing command also redirect both stdout and stderr to file, but it might not be well supported on all version and platform.

command &> output.log
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.