Question About Pipes

Adam Myrow amyrow at midsouth.rr.com
Wed Nov 5 23:15:17 EST 2003


On Wed, 5 Nov 2003, Rejean Proulx wrote:

> I tried program > outputfile and the errors still came to the screen and did
> not go to the file.

One thing that you have to realize about Linux and other Unix systems is
that there are both a standard output and a standard error.  Standard
output is called file descriptor 1, and standard error is file descriptor
2.  Most programs have non-error messages go to standard output, and error
messages go to standard error.  Standard output and standard error are
connected to your screen by default.  When you use the greater-than sign
as in "echo "Hello world." > hello.txt," you are only sending standard
output to hello.txt.  The "2>&1" says to point standard error to standard
output, thus your redirection gets both standard error and standard output
pointing to the same place.  They could also go to different places.  For
example, you could have only the errors in one file and the normal output
in another with the syntax "command > normal.out 2> errors."  You could
also redirect one or both to /dev/null which makes them invisible.  There
are a lot of things you can do once you get the hang of this.





More information about the Speakup mailing list