OT: ^ in redirection (windows)
Bengt Richter
bokr at oz.net
Mon Jul 4 10:43:07 EDT 2005
On 4 Jul 2005 13:07:02 GMT, Duncan Booth <duncan.booth at invalid.invalid> wrote:
>Miki Tebeka wrote:
>
>> Can someone explain me the difference between:
>> echo 1 > 1.txt 2>&1
>> and
>> echo 1 > 1.txt 2>^&1
>>
>> (Windows XP "cmd" shell)
>>
>> Both produce 1.txt with the content 1.
>>
>> (Sadly, I don't know how to search for ^ in google).
>>
>
>The first of these joins stderr to stdout, but since there is no output to
>stderr has no visible effect.
>
>The second should prevent special treatment of the & character, but in this
>particular case actually has no effect.
>
>You can see the effects more clearly if you redirect a handle which
>actually does have some output:
>
>stdout redirected to stderr, but stderr still goes to console so no visible
>effect:
>
>C:\temp>echo hi 1>&2
>hi
>
>stdout redirected to stderr, then stderr redirected to a file, but stdout
>still points at original stderr so no visible effect:
>
>C:\temp>echo hi 1>&2 2>x.txt
>hi
>
>stderr redirected to a file, then stdout redirected to same file. Output
>goes in a file:
>C:\temp>echo hi 2>x.txt 1>&2
>
>C:\temp>type x.txt
>hi
>
>Same as above. Using ^ to avoid special interpretation of the & has no
>effect:
>C:\temp>echo hi 2>x.txt 1>^&2
>
>C:\temp>type x.txt
>hi
>
You'd think ^ would be mentioned in
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx
but it seems not to be.
Regards,
Bengt Richter
More information about the Python-list
mailing list