问题描述
我将g ++编译器输出(stderr和stdout都重定向)到Linux上的文件.但是它正在创建一个空文件.
I am redirecting the g++ compiler output(both stderr and stdout) to a file on linux. But it is creating an empty file.
我在另一篇文章中读到,每行之后stdout不会被刷新.没关系,但是stderr呢.在我的情况下,运行多个屏幕时会出现编译错误.因此,我对stderr输出感兴趣.没有创建标准输出.
I read in some other post that stdout is not flushed after every line. Thats ok, but what about stderr. In my case there are compilation errors running several screens. So, I am interested in stderr output. There is no stdout output created.
g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ -I
~/cplusplus/niVxWorksDeliver/TEES/ Algorithms.cpp 2> output
上面的命令创建一个名为输出"的空文件.以下命令报告无效的空命令.
The above command creates an empty file named "output". The following command reports invalid null command.
g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ -I
~/cplusplus/niVxWorksDeliver/TEES/ Algorithms.cpp &> output
Invalid null command.
推荐答案
您的评论之一表明您没有使用bash.您正在使用csh或tcsh.在这种情况下,您可以像这样重定向所有输出(包括标准错误):
One of your comments betrays that you are not using bash. You're using csh or tcsh. In that case, you can redirect all output (including standard error) like this:
g++ -c Algorithms.cpp >& output
有关更多csh重定向语法,我在有用的链接中加了书签.请注意,csh重定向语法不如bash语法那么流利.在bash中比在csh中可以做更多的事情.
For more csh redirection syntax, I have a useful link bookmarked. Note that csh redirection syntax is not as fluent as bash syntax. You can do more in bash than you can in csh.
这篇关于linux g ++编译器重定向stderr和stdout创建空文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!