Linux g ++ redirect stderr and stdout compiler creates empty file

I redirect the output of the g ++ compiler (both stderr and stdout) to a file in linux. But it creates an empty file.

I read in another post that stdout will not turn red after each line. This is fine, but what about stderr. In my case, there are compilation errors with multiple screens. So, I'm interested in stderr output. No stdout output generated.

 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 called "output". The following command reports an 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.
+5
source share
3 answers

, bash. csh tcsh. ( ) :

g++ -c Algorithms.cpp >& output

csh, . , csh , bash. bash, csh.

+11

:

sh/bash/ zsh:

g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ \
       -I ~/cplusplus/niVxWorksDeliver/TEES/ \
       Algorithms.cpp > output 2>&1

csh tcsh:

g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ \
       -I ~/cplusplus/niVxWorksDeliver/TEES/ \
       Algorithms.cpp >& output
+3

" - " - - ? , g++ !

0

All Articles