问题
So gnu has stdbuf which allows you to modify buffering of a command's I/O stream. I need the same functionality for command prompt but I can't seem to find anything about it.
I'm simply trying to output both stdout and stderr of a program, to a logfile, without buffering (or rather, just so that they are in sync and in the same order they would be displayed as in the console).
Did I just miss some obvious command or syntax, or am I just out of luck in windows?
回答1:
Take a look at this. I don't have Windows to test on, but my guess is that you would need something like this:
.\foo.bat > .\bar.log 2>&1
This will default to buffered IO, which is not exactly what you want, but unbuffered output does not seem to be possible.
来源:https://stackoverflow.com/questions/13317375/is-there-an-stdbuf-equivalent-for-windows-7-command-prompt