菜鸟又问问题拉,2> /dev/null与> /dev/null 2>&1有何区别

[复制链接]
查看11 | 回复2 | 2011-11-1 16:20:28 | 显示全部楼层 |阅读模式
菜鸟又问问题拉,2> /dev/null与> /dev/null 2>&1有何区别
我知道都是重定向到NULL,不输出结果显示,可是那个2和 2>&1是啥意思啊,每次都是用了,但是不知所以然.
原谅我又问问题
回复

使用道具 举报

千问 | 2011-11-1 16:20:28 | 显示全部楼层
1 - denotes stdout ( standard output )
2 - denotes stderr( standard error )
/dev/null . apparently is null , nothing , empty , zero etc , etc .
2>/dev/null - redirect stderr to nothing , it turns stderr off.
>/dev/null 2>&1 also can writeas1>/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
a little practice may help to undstand above .
#ls /usr/nothing
#ls /usr/nothing2>/dev/null
#ls /usr/nothing>/dev/null 2>&1
hehe, 清楚的不得了,谢谢各位大虾.
回复

使用道具 举报

千问 | 2011-11-1 16:20:28 | 显示全部楼层
原谅我的自问自答,别人告诉我的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行