Is there a way to distinguish stderr in the console release?

This displays both threads on the console, but somehow distinguishes one from the other.

I usually donโ€™t know which stderr lines are mixed with normal output. If I redirect it to a file, then I do not know when an error occurred due to the normal output. So, is there a way that every line that came from stderr would have some indicator, for example, for example, a line at the beginning:

c:\>command.exe normal output normal output normal output stderr: error message normal output stderr: error message normal output 

This is especially a problem in / make compilers, which output a lot of information and mix these two streams. I know that I can add every line of text with a given line using unix sed , but I don't know how to use it in relation to the main program. If I join two streams, a line will be added to each line. If I redirect stderr to a file, it will not be displayed on console +, it will go out of context from stdout.

+4
source share
1 answer

If the goal is to distinguish error messages from normal single-screen output, this can be done with this trick:

 anycompiler params ... 2>&1 1>&3 | findstr /N /A:4E "^" 

Thus, error messages precede a yellow line number on a red background.

Previous answer extracted from: Batch - How can I redirect stderr and stdout from the script package itself?

If you redirect both outputs of the previous line to the disk file, the STDERR output will be preceded by the line number.

+2
source

Source: https://habr.com/ru/post/1482855/


All Articles