This question is old, but you could do this, which facilitates reading:
>&2 echo "error"
The operator '>&2' literally means redirect the address of file descriptor 1 (stdout) to the address of file descriptor 2 (stderr) for that command. depending on how deeply you want to understand it, read this: http://wiki.bash-hackers.org/howto/redirection_tutorial
To avoid interaction with other redirections use subshell
(>&2 echo "error")
本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6707260.html
,如需转载请自行联系原作者