Standard Error


In addition to standard input and standard output, there is another place known as standard error. This is where most Unix commands write their error messages. And as with the other two "standard" places, standard error is associated with your terminal by default. In most cases, you never know the difference between standard output and standard error:


[root@server1 ~]# ls n*
ls: n*: No such file or directory

 [root@server1 ~]# ls n* > foo
ls: n*: No such file or directory

You can also redirect standard error to a file by using the notation
command 2> file

No space is permitted between the 2 and the >. Any error messages normally intended for standard error will be diverted into the specified file, similar to the way standard output gets redirected.
[root@server1 ~]# ls n* 2> errors [root@server1 ~]# cat errors ls: n*: No such file or directory



Comments

Popular posts from this blog

Shell Basic Operators.

AWK