简体   繁体   English

在Windows中,2 <&1和2>&1之间有什么区别?

[英]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<&1 findfile 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>&1 ipconfig.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.

相关问题 Windows中的socket和HANDLE有什么区别? - What's the difference between socket and HANDLE in Windows? Windows版Docker和Windows版Docker有什么区别? - What's the difference between Docker for Windows and Docker on Windows? Delphi中这些Windows API签名之间有什么区别? - What's the difference between these Windows API signatures in Delphi? Windows 文件夹结构中的“访问”时间和“修改”时间有什么区别? - What's the difference between 'access' and 'modified' times in Windows folder structure? Windows C API:wincrypt和sspi有什么区别? - Windows C API: what's the difference between wincrypt and sspi? Windows服务和Windows进程之间有什么区别? - What the difference between a Windows service and a Windows process? Java windows 在线安装和 Java windows 离线安装有什么区别? - what's the difference between Java windows online Installation and Java windows offline Installation? Windows可执行文件的“数据目录”条目和“节头”条目之间有什么区别? - What's the difference between a Windows executable's Data Directory entry and Section Header entry? Unity3D的Windows Store版本和PC Standalone版本之间有什么区别? - What's the difference between Unity3D's Windows Store build and PC Standalone build? Shell注册表中的Shell和ShellEx有什么区别? - What is the difference between Shell and ShellEx in Windows Registry?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM