Reputation: 29615
The examples and explanations in this page are leaving me confused:
Is there any practical difference between using 2<&1 and 2>&1? The second form (2>&1) is familiar to me, from working with the Unix shell.
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:
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:
ipconfig.exe>>output.log 2>&1
In the end, is there any difference in the results?
Upvotes: 14
Views: 38559
Reputation: 3503
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.
c:\YourDir>cd > nul
You get nothing, the output stream goes to 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.
c:\YourDir>cd > nul 1<&2
This seams to do the same as 1>&2
Upvotes: 13