2016-08-04 102 views
1

“1> & 2”在bash脚本中是什么意思?“1>&2”在bash中的含义是什么?

例如,bash脚本中的以下行是做什么的?

echo "$1 is not a directory!" 1>&2 

我使用的是mac os x。我的bash脚本是:

if [ ! -d $1 ]; then 
    echo "$1 is not a directory" 1>&2 
    exit 1 
fi 
+3

“'1&2#将stdout重定向到stderr.” - 来自[I/O重定向](http://www.tldp.org/LDP/abs/html/io-redirection.html) –

+3

搜索对于'[bash]“1&2”'显示799 Q/A。在发布之前你有没有打扰过?祝你好运。 – shellter

+0

@shellter无需发表重复的评论说同样的事情。 –

回答