Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 861
theglauber Avatar asked Jan 18 '12 15:01

theglauber


People also ask

What is difference between MS DOS and MS Window?

DOS is a single tasking, single user and is CLI based OS whereas Windows is a multitasking, multiuser and GUI based OS.

What's the difference Windows 10 and 11?

A major difference between Windows 11 and Windows 10 is in its design. Windows 11 offers an interface that's more like a Mac, with pastel colors, rounded corners for all windows and a cleaner interface than its predecessor.


1 Answers

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

like image 157
Andy Morris Avatar answered Oct 26 '22 16:10

Andy Morris