[Linux] Redirect the standard error to standard output and files

When we compile some project, we may want to catch compile-time error message for debugging use. Unfortunately, you can’t just redirect the error messages to a file, because it outputs the error messages to STDERR (fd 2). For this reason, you have to redirect the STDERR to the STDOUT, and then, to use the pipe to transfer these messages into the tee.

The command should be like,

#> make 2>&1 | tee log.file

Note:

The tee is a tool for user to write some data from input into standard output and files. You can also see the “man tee”.

You can get more information of STDIN, STDOUT, and STDERR from LinuxSA.

2 comments

  1. Hi! You can pick up my blog by clicking the "add a subscription" button in the google reader website. This button is located in the top-left of the google reader website. Thanks.

發佈留言