Redirect Windows cmd stdout and stderr to a single file

前端 未结 7 1880
醉梦人生
醉梦人生 2020-11-22 10:11

I\'m trying to redirect all output (stdout + stderr) of a DOS command to a single file:

C:\\>dir 1> a.txt 2> a.txt
The process cannot access the fil         


        
7条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 10:59

    There is, however, no guarantee that the output of SDTOUT and STDERR are interweaved line-by-line in timely order, using the POSIX redirect merge syntax.

    If an application uses buffered output, it may happen that the text of one stream is inserted in the other at a buffer boundary, which may appear in the middle of a text line.

    A dedicated console output logger (I.e. the "StdOut/StdErr Logger" by 'LoRd MuldeR') may be more reliable for such a task.

    See: MuldeR's OpenSource Projects

提交回复
热议问题