Chinaunix

标题: 2>&1 < /dev/null 求解 [打印本页]

作者: levinpluto    时间: 2012-05-02 00:54
标题: 2>&1 < /dev/null 求解
今天遇到一个脚本,里面有这样一行:

bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-

我完全不理解 2>&1 < /dev/null这段是什么意思。

我尝试 bzip2 --version 以及 bzip2 --version 2>&1 < /dev/null 这两种写法输出是完全一样的,搞不懂这边想表达什么含义,以及 < /dev/null是什么意思。

求指教。
作者: Shell_HAT    时间: 2012-05-02 02:50
这个脚本的其它地方有没有对2号句柄进行输出重定向?
作者: yinyuemi    时间: 2012-05-02 06:30
本帖最后由 yinyuemi 于 2012-05-02 06:31 编辑

回复 1# levinpluto




/dev/null 空文件
2>&1 标准错误重定向为标准输出

man bzip2
If no file names are specified, bzip2 compresses from standard input to standard  output.
       In  this case, bzip2 will decline to write compressed output to a terminal
, as this would
       be entirely incomprehensible and therefore pointless.

作者: waker    时间: 2012-05-02 08:50
http://bbs.chinaunix.net/tree/index_159_1/
作者: yuhuohu    时间: 2012-05-02 10:12
还能够</dev/null??
从来都是>/dev/null
作者: ecjtubaowp    时间: 2012-05-02 10:34
学习了。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2