Chinaunix

标题: 请教:这段脚本是什么意思 [打印本页]

作者: 通用寄存器    时间: 2007-11-16 16:27
标题: 请教:这段脚本是什么意思
# Redirecting only stderr to a pipe.
exec 3>&1                                                         # Save current "value" of stdout.
ls -l 2>&1 >&3 3>&- | grep bad 3>&-                # Close fd 3 for 'grep' (but not 'ls').
exec 3>&-                                                         # Now close it for the remainder of the script.


被这几个重定向搞晕了,在第三行里为什么关闭fd3两次呢

[ 本帖最后由 通用寄存器 于 2007-11-16 16:45 编辑 ]
作者: davistar    时间: 2007-11-16 16:32
管道两边的都是subshell
最后关闭的是当前shell
作者: nuclearxin    时间: 2007-11-16 16:40
天书~~~~
根本看不同
那位兄台只个方向 我去复习
作者: 通用寄存器    时间: 2007-11-16 17:15
原来CU上已经讨论过了
http://bbs.chinaunix.net/viewthread.php?tid=221848
CU真神奇啊




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