You are expecting output from a program but you don’t want it to get littered with error messages. You’d like to save your error messages, but it’s harder to find them mixed among the expected output.
Redirect output and error messages to different files.
$ myprogram 1> messages.out 2> message.err
Or more commonly:
$ myprogram > messages.out 2> message.err
This example shows two different output files that will be created by the shell. The first, messages.out, will get all the output from the hypothetical myprogram redirected into it. Any error messages from myprogram will be redirected into message.err.
In the constructs 1>
and
2>
the number is the file
descriptor, so 1 is STDOUT and 2 is STDERR. When no number is specified,
STDOUT is assumed.
3.22.242.141