how to force to redirect the message on the screen?
I am running a C++ program and there are other underling code.
When I run it, suppose it is a.exe, there are a lot of information printed on the screen. I can't redirect some inf开发者_StackOverflowormation to a .txt file like ./a.ext > temp.txt
How can I force it is redirect to the temp.txt?
Thanks!
POSIX
Reditect STDOUT and STDERR
./a.ext &> temp.txt
Or you can use equivalent from windows format.
./a.ext >& temp.txt
Windows (Reditect STDOUT and STDERR)
Reditect STDOUT and STDERR
./a.ext >& temp.txt
More information about this you can find at Using command redirection operators at Microsoft Technet
Some of the information may be written stderr. In order to catch both stdout and stderr, you should use
./a.ext > temp.txt 2>&1
加载中,请稍侯......
精彩评论