[英]In Windows, what's the difference between 2<&1 and 2>&1?
The examples and explanations in this page are leaving me confused: 本页中的示例和解释让我感到困惑:
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
Is there any practical difference between using 2<&1 and 2>&1? 使用2 <&1和2>&1之间有什么实际区别吗? The second form (2>&1) is familiar to me, from working with the Unix shell.
使用Unix shell时,第二种形式(2>和1)对我来说很熟悉。
The page linked above has: 上面链接的页面包含:
To find File.txt, and then redirect handle 1 (that is, STDOUT) and handle 2 (that is, STDERR) to the Search.txt, type:
要查找File.txt,然后将句柄1(即STDOUT)和句柄2(即STDERR)重定向到Search.txt,请键入:
findfile file.txt>search.txt 2<&1findfile file.txt> search.txt 2 <&1
and also 并且
To redirect all of the output, including handle 2 (that is, STDERR), from the ipconfig command to handle 1 (that is, STDOUT), and then redirect the ouput to Output.log, type:
要将所有输出(包括句柄2(即STDERR))从ipconfig命令重定向到句柄1(即STDOUT),然后将输出重定向到Output.log,请键入:
ipconfig.exe>>output.log 2>&1ipconfig.exe >> output.log 2>&1
In the end, is there any difference in the results? 最后,结果有什么不同吗?
Some examples should show what happens: 一些例子应该显示会发生什么:
c:\YourDir> cd FolderNotHere > nul
The system cannot find the path specified.
You get the error stream 你得到错误流
c:\YourDir>cd FolderNotHere > nul 2>&1
You get nothing, the error stream goes to the std output stream which goes to null. 什么都没得到,错误流转到std输出流,该流变为null。
c:\YourDir>cd > nul
You get nothing, the output stream goes to null. 什么也没得到,输出流变为null。
c:\YourDir>cd > nul 1>&2
c:\YourDir
You get the std outout which has been sent to the error stream so it doesn't get redirected. 您将获得已发送到错误流的std outout,因此不会重定向。
c:\YourDir>cd > nul 1<&2
This seams to do the same as 1>&2 这种接缝与1>&2相同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.