本页中的示例和解释让我感到困惑:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
使用 2&1 之间有什么实际区别吗?第二种形式 (2>&1) 是我在使用 Unix shell 时所熟悉的。
上面链接的页面有:
要查找 File.txt,然后将句柄 1(即 STDOUT)和句柄 2(即 STDERR)重定向到 Search.txt,请键入:
findfile file.txt>search.txt 2
and also
要将所有输出(包括句柄 2(即 STDERR))从 ipconfig 命令重定向到句柄 1(即 STDOUT),然后将输出重定向到 Output.log,请键入:
ipconfig.exe>>输出.log 2>&1
最后,结果有什么不同吗?
一些例子应该显示会发生什么:
c:\YourDir> cd FolderNotHere > nul
The system cannot find the path specified.
你得到错误流
c:\YourDir>cd FolderNotHere > nul 2>&1
您什么也得不到,错误流转到 std 输出流,该输出流变为 null。
c:\YourDir>cd > nul
您什么也得不到,输出流变为空。
c:\YourDir>cd > nul 1>&2
c:\YourDir
您将获得已发送到错误流的标准输出,因此它不会被重定向。
c:\YourDir>cd > nul 1<&2
这似乎与 1>& 2 的作用相同
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)