1>/dev/null and 2>/dev/null意义

来源:互联网 发布:全球监控软件排行 编辑:程序博客网 时间:2024/05/16 02:02
A. 
1> /dev/null 表示将命令的标准输出重定向到 /dev/null
2>/dev/null 表示将命令的错误输出重定向到 /dev/null



1 - denotes stdout ( standard output )

2 - denotes stderr  ( standard error )

/dev/null就相当与windows里的回收站,只是进去了不能再出来了。

>/dev/null 就是将标准输出和标准出错的信息屏蔽不显示




B.

>/dev/null 2>&1   also can write  as  1>/dev/null 2>&1    
- stdout redirect to /dev/null (no stdout) ,and redirect stderr to stdout  (stderr gone as well) . end up it turns both stderr and stdout off




C.

a little practice may help to undstand above .  

#ls /usr  /nothing

#ls /usr  /nothing  2>/dev/null

#ls /usr  /nothing  >/dev/null 2>&1
原创粉丝点击