问题
For example I need to set two tee commands in such way that one will be reading from STDOUT and second from STDERR and both redirecting the console output to different files. Is such thing possible in windows batch files ? I know about how to redirect output to file but in this case it won't be displayed on screen or how to combine both streams but how about piping both independently ?
回答1:
You may process STDOUT and STDERR with separate programs via the next trick:
(test | findstr /N /A:2A "^" ) 2>&1 1>&3 | findstr /N /A:4E "^"
Previous line show STDOUT output preceded by green numbers and STDERR output preceded by red ones. Just use your TEE program instead findstr...
If you have not an adequate TEE program for Batch files, you may find one here: Displaying Windows command prompt output and redirecting it to a file
回答2:
You can redirect stdout and stderr to different files but that's about as far as it goes.
If the make output can be time coded on every line then the two files could be adjusted and re-interleaved.
来源:https://stackoverflow.com/questions/16762674/is-there-a-way-to-pipe-stderr-and-stdout-to-different-programs