There are two main output streams in Linux (and other OSs), standard output (stdout) and standard error (stderr). Error messages, like the ones you show, are printed to standard error. The classic redirection operator (command > file
) only redirects standard output, so standard error is still shown on the terminal. To redirect stderr as well, you have a few choices:
Redirect stdout to one file and stderr to another file:
command > out 2>error
Redirect stdout to a file (
>out
), and then redirect stderr to stdout (2>&1
):command >out 2>&1
Redirect both to a file (this isn't supported by all shells,
bash
andzsh
support it, for example, butsh
andksh
do not):command &> out
For more information on the various control and redirection operators, see here.
No comments:
Post a Comment