echo 到 stderr

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")
posted @ 2017-04-14 09:33  bonelee  阅读(358)  评论(0编辑  收藏  举报