Standard Error and Standard Output

The echo command prints to standard output. However we know that it is good practice to redirect the error messages to standard error, lest the errors be redirected along with the output.

So, many languages provide features for writing to the standard error. (example: sys.stderr for Python)

For bash users, it is possible to redirect the echo output to standard error. We use the 1>&2 operator.

$ echo “#Error: Invalid calculation” 1>&2

Remember, this works only with bourne shells


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: